mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-06 21:15:22 +00:00
virsh: Don't generate invalid XML in attach-disk command
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.
(cherry picked from commit 5b4740265c
)
This commit is contained in:
parent
661a2e83ef
commit
73908b1d10
@ -14493,18 +14493,18 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAddLit(&buf, " rawio='yes'");
|
virBufferAddLit(&buf, " rawio='yes'");
|
||||||
virBufferAddLit(&buf, ">\n");
|
virBufferAddLit(&buf, ">\n");
|
||||||
|
|
||||||
if (driver || subdriver)
|
if (driver || subdriver || cache) {
|
||||||
virBufferAsprintf(&buf, " <driver");
|
virBufferAsprintf(&buf, " <driver");
|
||||||
|
|
||||||
if (driver)
|
if (driver)
|
||||||
virBufferAsprintf(&buf, " name='%s'", driver);
|
virBufferAsprintf(&buf, " name='%s'", driver);
|
||||||
if (subdriver)
|
if (subdriver)
|
||||||
virBufferAsprintf(&buf, " type='%s'", subdriver);
|
virBufferAsprintf(&buf, " type='%s'", subdriver);
|
||||||
if (cache)
|
if (cache)
|
||||||
virBufferAsprintf(&buf, " cache='%s'", cache);
|
virBufferAsprintf(&buf, " cache='%s'", cache);
|
||||||
|
|
||||||
if (driver || subdriver || cache)
|
|
||||||
virBufferAddLit(&buf, "/>\n");
|
virBufferAddLit(&buf, "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (source)
|
if (source)
|
||||||
virBufferAsprintf(&buf, " <source %s='%s'/>\n",
|
virBufferAsprintf(&buf, " <source %s='%s'/>\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user