]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach disk
authorPeter Krempa <pkrempa@redhat.com>
Thu, 12 Mar 2015 10:51:51 +0000 (11:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 17 Mar 2015 16:11:37 +0000 (17:11 +0100)
Since cmdDetachDisk() calls into vshPrepareDiskXML() with
type == VSH_PREPARE_DISK_XML_NONE && source == NULL this would result
into skipping all the checks and effectively turn the function into a
XML formatter.

This patch changes the code to use the formatter directly so that the
function can be refactored in a easier way.

tools/virsh-domain.c

index b4e9cb0bf2524e18475a4d17c91bd2023089264e..eea95174efd031ff4cc88ce4c188f81e4aeb0066 100644 (file)
@@ -11365,9 +11365,10 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     if (!(disk_node = vshFindDisk(doc, target, VSH_FIND_DISK_NORMAL)))
         goto cleanup;
 
-    if (!(disk_xml = vshPrepareDiskXML(disk_node, NULL, NULL,
-                                       VSH_PREPARE_DISK_XML_NONE)))
+    if (!(disk_xml = virXMLNodeToString(NULL, disk_node))) {
+        vshSaveLibvirtError();
         goto cleanup;
+    }
 
     if (flags != 0 || current)
         ret = virDomainDetachDeviceFlags(dom, disk_xml, flags);