mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
virsh: cmdBlockcopy: Use virXMLFormatElement
Rewrite the formatting of the block copy target xml using virXMLFormatElement. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
823a62ec8a
commit
1cd95f858a
@ -2475,14 +2475,20 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (!xmlstr) {
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
virBufferAsprintf(&buf, "<disk type='%s'>\n",
|
||||
blockdev ? "block" : "file");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<source %s", blockdev ? "dev" : "file");
|
||||
virBufferEscapeString(&buf, "='%s'/>\n", dest);
|
||||
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
if (blockdev) {
|
||||
virBufferAddLit(&attrBuf, " type='block'");
|
||||
virBufferAddLit(&childBuf, "<source dev=");
|
||||
} else {
|
||||
virBufferAddLit(&buf, " type='file'");
|
||||
virBufferAddLit(&childBuf, "<source file=");
|
||||
}
|
||||
|
||||
virBufferEscapeString(&buf, "'%s'/>\n", dest);
|
||||
virBufferEscapeString(&buf, "<driver type='%s'/>\n", format);
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</disk>\n");
|
||||
virXMLFormatElement(&buf, "disk", &attrBuf, &childBuf);
|
||||
xmlstr = virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user