Skip to content

Commit

Permalink
qemu/xen: make use of xenstore relative paths
Browse files Browse the repository at this point in the history
Qemu has several hardcoded xenstore paths that are only valid on Dom0.
Attempts to launch a Qemu instance (to act as a userspace backend for
PV disks) will fail because Qemu is not able to access those paths
when running on a domain different than Dom0.

Instead make the xenstore paths relative to the domain where Qemu is
actually running.

Signed-off-by: Roger Pau Monné <[email protected]>
Signed-off-by: Stefano Stabellini <[email protected]>
Reviewed-by: Anthony PERARD <[email protected]>
Cc: [email protected]
Cc: Anthony PERARD <[email protected]>
  • Loading branch information
royger authored and Stefano Stabellini committed Oct 10, 2013
1 parent a76f48e commit 33876df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions hw/xen/xen_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
char *dom0;

xendev = xen_be_find_xendev(type, dom, dev);
if (xendev) {
Expand All @@ -219,12 +218,10 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
xendev->dev = dev;
xendev->ops = ops;

dom0 = xs_get_domain_path(xenstore, 0);
snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",
dom0, xendev->type, xendev->dom, xendev->dev);
snprintf(xendev->be, sizeof(xendev->be), "backend/%s/%d/%d",
xendev->type, xendev->dom, xendev->dev);
snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
xendev->type, xendev->dev);
free(dom0);

xendev->debug = debug;
xendev->local_port = -1;
Expand Down Expand Up @@ -570,14 +567,12 @@ static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops)
{
struct XenDevice *xendev;
char path[XEN_BUFSIZE], token[XEN_BUFSIZE];
char **dev = NULL, *dom0;
char **dev = NULL;
unsigned int cdev, j;

/* setup watch */
dom0 = xs_get_domain_path(xenstore, 0);
snprintf(token, sizeof(token), "be:%p:%d:%p", type, dom, ops);
snprintf(path, sizeof(path), "%s/backend/%s/%d", dom0, type, dom);
free(dom0);
snprintf(path, sizeof(path), "backend/%s/%d", type, dom);
if (!xs_watch(xenstore, path, token)) {
xen_be_printf(NULL, 0, "xen be: watching backend path (%s) failed\n", path);
return -1;
Expand All @@ -603,12 +598,10 @@ static void xenstore_update_be(char *watch, char *type, int dom,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
char path[XEN_BUFSIZE], *dom0, *bepath;
char path[XEN_BUFSIZE], *bepath;
unsigned int len, dev;

dom0 = xs_get_domain_path(xenstore, 0);
len = snprintf(path, sizeof(path), "%s/backend/%s/%d", dom0, type, dom);
free(dom0);
len = snprintf(path, sizeof(path), "backend/%s/%d", type, dom);
if (strncmp(path, watch, len) != 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion xen-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
exit(1);
}

snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", xen_domid);
snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
fprintf(stderr, "error recording dm state\n");
exit(1);
Expand Down

0 comments on commit 33876df

Please sign in to comment.