]> xenbits.xensource.com Git - xen.git/commitdiff
xl: main_blockdetach don't call destroy if remove succeeds
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 26 Jul 2012 09:35:33 +0000 (10:35 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Thu, 26 Jul 2012 09:35:33 +0000 (10:35 +0100)
xl was calling libxl_device_disk_destroy after a successful call to
libxl_device_disk_remove, which leads to an error.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/xl_cmdimpl.c

index 26fcf13f496e3c68e8aa9013a1c81cccdacd9dc0..7f5cadc81d8c8a98756421b09b07b76cedafa7c6 100644 (file)
@@ -5398,7 +5398,7 @@ int main_blocklist(int argc, char **argv)
 
 int main_blockdetach(int argc, char **argv)
 {
-    int opt;
+    int opt, rc = 0;
     libxl_device_disk disk;
 
     if ((opt = def_getopt(argc, argv, "", "block-detach", 2)) != -1)
@@ -5412,11 +5412,12 @@ int main_blockdetach(int argc, char **argv)
         fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
         return 1;
     }
-    if (libxl_device_disk_remove(ctx, domid, &disk, 0)) {
+    rc = libxl_device_disk_remove(ctx, domid, &disk, 0);
+    if (rc) {
         fprintf(stderr, "libxl_device_disk_remove failed.\n");
-    } else
-        libxl_device_disk_destroy(ctx, domid, &disk, 0);
-    return 0;
+    }
+    libxl_device_disk_dispose(&disk);
+    return rc;
 }
 
 static char *uptime_to_string(unsigned long time, int short_mode)