]> xenbits.xensource.com Git - qemu-xen-4.4-testing.git/commitdiff
Fix blktap device backend patch check
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 14 Oct 2008 10:46:53 +0000 (11:46 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 14 Oct 2008 10:46:53 +0000 (11:46 +0100)
Regarding http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1367,
it appears that the expected backend path check is too strict for'
blktap devices.  Therefore if the devtype is `vbd' we allow the
backend to be `tap'.

Thanks to report and inspiration from Yosuke Iwamatsu.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
xenstore.c

index f5aa8a7186fd1fe97b78a033e7fcde5816a4608c..5cd50638c8e87eecdfeaeeaa1c84ee8bdacaf854 100644 (file)
@@ -191,17 +191,36 @@ static void xenstore_get_backend_path(char **backend, const char *devtype,
     backend_dompath = xs_get_domain_path(xsh, domid_backend);
     if (!backend_dompath) goto out;
     
-    if (pasprintf(&expected_backend, "%s/backend/%s/%lu/%s",
-                  backend_dompath, devtype, frontend_domid, inst_danger)
-        == -1) goto out;
+    const char *expected_devtypes[3];
+    const char **expected_devtype = expected_devtypes;
+
+    *expected_devtype++ = devtype;
+    if (!strcmp(devtype, "vbd")) *expected_devtype++ = "tap";
+    *expected_devtype = 0;
+    assert(expected_devtype <
+           expected_devtypes + ARRAY_SIZE(expected_devtypes));
+
+    for (expected_devtype = expected_devtypes;
+         *expected_devtype;
+         expected_devtype++) {
+    
+        if (pasprintf(&expected_backend, "%s/backend/%s/%lu/%s",
+                      backend_dompath, *expected_devtype,
+                      frontend_domid, inst_danger)
+            == -1) goto out;
 
-    if (strcmp(bpath, expected_backend)) {
-        fprintf(stderr, "frontend `%s' expected backend `%s' got `%s',"
-                " ignoring\n", frontend_path, expected_backend, bpath);
-        errno = EINVAL;
-        goto out;
+        if (!strcmp(bpath, expected_backend))
+            goto found;
     }
 
+    fprintf(stderr, "frontend `%s' devtype `%s' expected backend `%s'"
+            " got `%s', ignoring\n",
+            frontend_path, devtype, expected_backend, bpath);
+    errno = EINVAL;
+    goto out;
+
+ found:
+
     if (pasprintf(&backend_frontend_path, "%s/frontend", bpath)
         == -1) goto out;