[PATCH 1/2] virsh: Don't generate invalid XML in attach-disk command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 98305c0..1862500 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -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",
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]