[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Get rid of xenbus_uuid_to_domid - get the frontend id from the node.
# HG changeset patch # User cl349@xxxxxxxxxxxxxxxxxxxx # Node ID a028975ecc05cd4d14e7bc568d16cc4b8d48c47a # Parent b0893b876c8c4c4eb507d48fc1c4af4268ddecde Get rid of xenbus_uuid_to_domid - get the frontend id from the node. We don't want to parse paths we read out of the store to _construct_ other paths and tie down the store layout for no good reason. Also require the frontend path to exist and be valid before creating the device. Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx> diff -r b0893b876c8c -r a028975ecc05 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Thu Aug 18 19:15:22 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Thu Aug 18 19:21:09 2005 @@ -109,47 +109,41 @@ }, }; -/* For backends, does lookup on uuid (up to /). Returns domid, or -errno. */ -int xenbus_uuid_to_domid(const char *uuid) -{ - int err, domid, len; - char path[strlen("/domain/") + 50]; - - len = strcspn(uuid, "/"); - if (snprintf(path, sizeof(path), "/domain/%.*s", len, uuid) - >= sizeof(path)) - return -ENOSPC; - err = xenbus_scanf(path, "id", "%i", &domid); - if (err != 1) - return err; - return domid; -} - /* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */ static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename) { - unsigned int typelen, uuidlen; - int domid; - const char *p; - - nodename = strchr(nodename, '/'); - if (!nodename) + int domid, err; + const char *devid, *type, *frontend; + unsigned int typelen; + + type = strchr(nodename, '/'); + if (!type) return -EINVAL; - nodename++; - typelen = strcspn(nodename, "/"); - if (!typelen || nodename[typelen] != '/') + type++; + typelen = strcspn(type, "/"); + if (!typelen || type[typelen] != '/') return -EINVAL; - p = nodename + typelen + 1; - uuidlen = strcspn(p, "/"); - if (!uuidlen || p[uuidlen] != '/') - return -EINVAL; - domid = xenbus_uuid_to_domid(p); - if (domid < 0) - return domid; - p += uuidlen + 1; + + devid = strrchr(nodename, '/') + 1; + + err = xenbus_gather(nodename, "frontend-id", "%i", &domid, + "frontend", NULL, &frontend, + NULL); + if (err) + return err; + if (strlen(frontend) == 0) + err = -ERANGE; + + if (!err && !xenbus_exists(frontend, "")) + err = -ENOENT; + + if (err) { + kfree(frontend); + return err; + } if (snprintf(bus_id, BUS_ID_SIZE, - "%.*s-%i-%s", typelen, nodename, domid, p) >= BUS_ID_SIZE) + "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE) return -ENOSPC; return 0; } diff -r b0893b876c8c -r a028975ecc05 linux-2.6-xen-sparse/include/asm-xen/xenbus.h --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Thu Aug 18 19:15:22 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h Thu Aug 18 19:21:09 2005 @@ -126,9 +126,6 @@ void unregister_xenbus_watch(struct xenbus_watch *watch); void reregister_xenbus_watches(void); -/* For backends, does lookup on uuid (up to /). Returns domid, or -errno. */ -int xenbus_uuid_to_domid(const char *uuid); - /* Called from xen core code. */ void xenbus_suspend(void); void xenbus_resume(void); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |