mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virsh: eliminate hardcoded indentation in xml generated for commands
These are never seen externally, only passed into libvirt APIs, so in practice this makes no real difference, but it's good to be consistent.
This commit is contained in:
parent
5f84543772
commit
64bb902451
@ -566,12 +566,13 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* Make XML of disk */
|
||||
virBufferAsprintf(&buf, "<disk type='%s'",
|
||||
(isFile) ? "file" : "block");
|
||||
isFile ? "file" : "block");
|
||||
if (type)
|
||||
virBufferAsprintf(&buf, " device='%s'", type);
|
||||
if (vshCommandOptBool(cmd, "rawio"))
|
||||
virBufferAddLit(&buf, " rawio='yes'");
|
||||
virBufferAddLit(&buf, ">\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
if (driver || subdriver || cache) {
|
||||
virBufferAddLit(&buf, "<driver");
|
||||
@ -588,8 +589,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (source)
|
||||
virBufferAsprintf(&buf, "<source %s='%s'/>\n",
|
||||
(isFile) ? "file" : "dev",
|
||||
source);
|
||||
isFile ? "file" : "dev", source);
|
||||
virBufferAsprintf(&buf, "<target dev='%s'/>\n", target);
|
||||
if (mode)
|
||||
virBufferAsprintf(&buf, "<%s/>\n", mode);
|
||||
@ -645,6 +645,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</disk>\n");
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
@ -876,6 +877,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* Make XML of interface */
|
||||
virBufferAsprintf(&buf, "<interface type='%s'>\n", type);
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
if (typ == 1)
|
||||
virBufferAsprintf(&buf, "<source network='%s'/>\n", source);
|
||||
@ -893,6 +895,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (inboundStr || outboundStr) {
|
||||
virBufferAddLit(&buf, "<bandwidth>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
if (inboundStr && inbound.average > 0) {
|
||||
virBufferAsprintf(&buf, "<inbound average='%llu'", inbound.average);
|
||||
if (inbound.peak > 0)
|
||||
@ -909,6 +912,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||
virBufferAsprintf(&buf, " burst='%llu'", outbound.burst);
|
||||
virBufferAddLit(&buf, "/>\n");
|
||||
}
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</bandwidth>\n");
|
||||
}
|
||||
|
||||
|
@ -251,9 +251,11 @@ vshBuildPoolXML(vshControl *ctl,
|
||||
goto cleanup;
|
||||
|
||||
virBufferAsprintf(&buf, "<pool type='%s'>\n", type);
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<name>%s</name>\n", name);
|
||||
if (srcHost || srcPath || srcDev || srcFormat || srcName) {
|
||||
virBufferAddLit(&buf, "<source>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
if (srcHost)
|
||||
virBufferAsprintf(&buf, "<host name='%s'/>\n", srcHost);
|
||||
@ -266,13 +268,17 @@ vshBuildPoolXML(vshControl *ctl,
|
||||
if (srcName)
|
||||
virBufferAsprintf(&buf, "<name>%s</name>\n", srcName);
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</source>\n");
|
||||
}
|
||||
if (target) {
|
||||
virBufferAddLit(&buf, "<target>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<path>%s</path>\n", target);
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</target>\n");
|
||||
}
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</pool>\n");
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
@ -1374,15 +1380,19 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
|
||||
return false;
|
||||
}
|
||||
virBufferAddLit(&buf, "<source>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<host name='%s'", host);
|
||||
if (port)
|
||||
virBufferAsprintf(&buf, " port='%s'", port);
|
||||
virBufferAddLit(&buf, "/>\n");
|
||||
if (initiator) {
|
||||
virBufferAddLit(&buf, "<initiator>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<iqn name='%s'/>\n", initiator);
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</initiator>\n");
|
||||
}
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</source>\n");
|
||||
if (virBufferError(&buf)) {
|
||||
vshError(ctl, "%s", _("Out of memory"));
|
||||
|
@ -298,10 +298,12 @@ vshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
|
||||
virBufferAsprintf(buf, " snapshot='%s'", snapshot);
|
||||
if (driver || file) {
|
||||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
if (driver)
|
||||
virBufferAsprintf(buf, "<driver type='%s'/>\n", driver);
|
||||
if (file)
|
||||
virBufferEscapeString(buf, "<source file='%s'/>\n", file);
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</disk>\n");
|
||||
} else {
|
||||
virBufferAddLit(buf, "/>\n");
|
||||
@ -424,6 +426,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
goto cleanup;
|
||||
|
||||
virBufferAddLit(&buf, "<domainsnapshot>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferEscapeString(&buf, "<name>%s</name>\n", name);
|
||||
virBufferEscapeString(&buf, "<description>%s</description>\n", desc);
|
||||
|
||||
@ -435,12 +438,15 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (vshCommandOptBool(cmd, "diskspec")) {
|
||||
virBufferAddLit(&buf, "<disks>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
while ((opt = vshCommandOptArgv(cmd, opt))) {
|
||||
if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</disks>\n");
|
||||
}
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</domainsnapshot>\n");
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
|
@ -212,6 +212,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
goto cleanup;
|
||||
|
||||
virBufferAddLit(&buf, "<volume>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<name>%s</name>\n", name);
|
||||
virBufferAsprintf(&buf, "<capacity>%llu</capacity>\n", capacity);
|
||||
if (allocationStr)
|
||||
@ -219,7 +220,9 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (format) {
|
||||
virBufferAddLit(&buf, "<target>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<format type='%s'/>\n", format);
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</target>\n");
|
||||
}
|
||||
|
||||
@ -273,10 +276,12 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
/* Create XML for the backing store */
|
||||
virBufferAddLit(&buf, "<backingStore>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<path>%s</path>\n", snapshotStrVolPath);
|
||||
if (snapshotStrFormat)
|
||||
virBufferAsprintf(&buf, "<format type='%s'/>\n",
|
||||
snapshotStrFormat);
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</backingStore>\n");
|
||||
|
||||
/* Cleanup snapshot allocations */
|
||||
@ -284,6 +289,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
||||
virStorageVolFree(snapVol);
|
||||
}
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</volume>\n");
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user