From: Roger Pau Monne Date: Thu, 26 Jul 2012 09:35:33 +0000 (+0100) Subject: xl: main_blockdetach don't call destroy if remove succeeds X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~8142 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=38bc2d3b97d18bd59241e87b2ef33b80565aa31f;p=xen.git xl: main_blockdetach don't call destroy if remove succeeds 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 Acked-by: Ian Jackson Committed-by: Ian Campbell --- diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 26fcf13f49..7f5cadc81d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -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)