]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Don't generate invalid XML in attach-disk command
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Jun 2012 14:55:51 +0000 (16:55 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 14 Jun 2012 08:07:54 +0000 (10:07 +0200)
The attach-disk command used with parameter --cache created an invalid
XML snippet as the beginning of the <driver> element was not printed
when used solely with --cache and no other attribute to driver.

tools/virsh.c

index 98305c0d7e56cbabbf13b59eae82340e0e17184b..18625009ceb2641331b2fa2c5b7449c54b883b93 100644 (file)
@@ -14765,18 +14765,18 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         virBufferAddLit(&buf, " rawio='yes'");
     virBufferAddLit(&buf, ">\n");
 
-    if (driver || subdriver)
+    if (driver || subdriver || cache) {
         virBufferAsprintf(&buf, "  <driver");
 
-    if (driver)
-        virBufferAsprintf(&buf, " name='%s'", driver);
-    if (subdriver)
-        virBufferAsprintf(&buf, " type='%s'", subdriver);
-    if (cache)
-        virBufferAsprintf(&buf, " cache='%s'", cache);
+        if (driver)
+            virBufferAsprintf(&buf, " name='%s'", driver);
+        if (subdriver)
+            virBufferAsprintf(&buf, " type='%s'", subdriver);
+        if (cache)
+            virBufferAsprintf(&buf, " cache='%s'", cache);
 
-    if (driver || subdriver || cache)
         virBufferAddLit(&buf, "/>\n");
+    }
 
     if (source)
         virBufferAsprintf(&buf, "  <source %s='%s'/>\n",