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. --- tools/virsh-domain.c | 43 ++++++++++++++++++++++++------------------- tools/virsh-pool.c | 40 +++++++++++++++++++++++++--------------- tools/virsh-snapshot.c | 24 +++++++++++++++--------- tools/virsh-volume.c | 26 ++++++++++++++++---------- 4 files changed, 80 insertions(+), 53 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1d3c5f0..f6a3dc4 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -572,9 +572,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "rawio")) virBufferAddLit(&buf, " rawio='yes'"); virBufferAddLit(&buf, ">\n"); + virBufferAdjustIndent(&buf, 2); if (driver || subdriver || cache) { - virBufferAddLit(&buf, " <driver"); + virBufferAddLit(&buf, "<driver"); if (driver) virBufferAsprintf(&buf, " name='%s'", driver); @@ -587,18 +588,18 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) } if (source) - virBufferAsprintf(&buf, " <source %s='%s'/>\n", + virBufferAsprintf(&buf, "<source %s='%s'/>\n", (isFile) ? "file" : "dev", source); - virBufferAsprintf(&buf, " <target dev='%s'/>\n", target); + virBufferAsprintf(&buf, "<target dev='%s'/>\n", target); if (mode) - virBufferAsprintf(&buf, " <%s/>\n", mode); + virBufferAsprintf(&buf, "<%s/>\n", mode); if (serial) - virBufferAsprintf(&buf, " <serial>%s</serial>\n", serial); + virBufferAsprintf(&buf, "<serial>%s</serial>\n", serial); if (wwn) - virBufferAsprintf(&buf, " <wwn>%s</wwn>\n", wwn); + virBufferAsprintf(&buf, "<wwn>%s</wwn>\n", wwn); if (straddr) { if (str2DiskAddress(straddr, &diskAddr) != 0) { @@ -609,7 +610,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (STRPREFIX((const char *)target, "vd")) { if (diskAddr.type == DISK_ADDR_TYPE_PCI) { virBufferAsprintf(&buf, - " <address type='pci' domain='0x%04x'" + "<address type='pci' domain='0x%04x'" " bus ='0x%02x' slot='0x%02x' function='0x%0x'", diskAddr.addr.pci.domain, diskAddr.addr.pci.bus, diskAddr.addr.pci.slot, diskAddr.addr.pci.function); @@ -623,7 +624,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) } else if (STRPREFIX((const char *)target, "sd")) { if (diskAddr.type == DISK_ADDR_TYPE_SCSI) { virBufferAsprintf(&buf, - " <address type='drive' controller='%d'" + "<address type='drive' controller='%d'" " bus='%d' unit='%d' />\n", diskAddr.addr.scsi.controller, diskAddr.addr.scsi.bus, diskAddr.addr.scsi.unit); @@ -634,7 +635,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) } else if (STRPREFIX((const char *)target, "hd")) { if (diskAddr.type == DISK_ADDR_TYPE_IDE) { virBufferAsprintf(&buf, - " <address type='drive' controller='%d'" + "<address type='drive' controller='%d'" " bus='%d' unit='%d' />\n", diskAddr.addr.ide.controller, diskAddr.addr.ide.bus, diskAddr.addr.ide.unit); @@ -645,6 +646,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) } } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</disk>\n"); if (virBufferError(&buf)) { @@ -876,25 +878,27 @@ 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); + virBufferAsprintf(&buf, "<source network='%s'/>\n", source); else if (typ == 2) - virBufferAsprintf(&buf, " <source bridge='%s'/>\n", source); + virBufferAsprintf(&buf, "<source bridge='%s'/>\n", source); if (target != NULL) - virBufferAsprintf(&buf, " <target dev='%s'/>\n", target); + virBufferAsprintf(&buf, "<target dev='%s'/>\n", target); if (mac != NULL) - virBufferAsprintf(&buf, " <mac address='%s'/>\n", mac); + virBufferAsprintf(&buf, "<mac address='%s'/>\n", mac); if (script != NULL) - virBufferAsprintf(&buf, " <script path='%s'/>\n", script); + virBufferAsprintf(&buf, "<script path='%s'/>\n", script); if (model != NULL) - virBufferAsprintf(&buf, " <model type='%s'/>\n", model); + virBufferAsprintf(&buf, "<model type='%s'/>\n", model); if (inboundStr || outboundStr) { - virBufferAddLit(&buf, " <bandwidth>\n"); + virBufferAddLit(&buf, "<bandwidth>\n"); + virBufferAdjustIndent(&buf, 2); if (inboundStr && inbound.average > 0) { - virBufferAsprintf(&buf, " <inbound average='%llu'", inbound.average); + virBufferAsprintf(&buf, "<inbound average='%llu'", inbound.average); if (inbound.peak > 0) virBufferAsprintf(&buf, " peak='%llu'", inbound.peak); if (inbound.burst > 0) @@ -902,14 +906,15 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virBufferAddLit(&buf, "/>\n"); } if (outboundStr && outbound.average > 0) { - virBufferAsprintf(&buf, " <outbound average='%llu'", outbound.average); + virBufferAsprintf(&buf, "<outbound average='%llu'", outbound.average); if (outbound.peak > 0) virBufferAsprintf(&buf, " peak='%llu'", outbound.peak); if (outbound.burst > 0) virBufferAsprintf(&buf, " burst='%llu'", outbound.burst); virBufferAddLit(&buf, "/>\n"); } - virBufferAddLit(&buf, " </bandwidth>\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</bandwidth>\n"); } virBufferAddLit(&buf, "</interface>\n"); diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index b21b682..3d0ea20 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -251,28 +251,34 @@ vshBuildPoolXML(vshControl *ctl, goto cleanup; virBufferAsprintf(&buf, "<pool type='%s'>\n", type); - virBufferAsprintf(&buf, " <name>%s</name>\n", name); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<name>%s</name>\n", name); if (srcHost || srcPath || srcDev || srcFormat || srcName) { - virBufferAddLit(&buf, " <source>\n"); + virBufferAddLit(&buf, "<source>\n"); + virBufferAdjustIndent(&buf, 2); if (srcHost) - virBufferAsprintf(&buf, " <host name='%s'/>\n", srcHost); + virBufferAsprintf(&buf, "<host name='%s'/>\n", srcHost); if (srcPath) - virBufferAsprintf(&buf, " <dir path='%s'/>\n", srcPath); + virBufferAsprintf(&buf, "<dir path='%s'/>\n", srcPath); if (srcDev) - virBufferAsprintf(&buf, " <device path='%s'/>\n", srcDev); + virBufferAsprintf(&buf, "<device path='%s'/>\n", srcDev); if (srcFormat) - virBufferAsprintf(&buf, " <format type='%s'/>\n", srcFormat); + virBufferAsprintf(&buf, "<format type='%s'/>\n", srcFormat); if (srcName) - virBufferAsprintf(&buf, " <name>%s</name>\n", srcName); + virBufferAsprintf(&buf, "<name>%s</name>\n", srcName); - virBufferAddLit(&buf, " </source>\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</source>\n"); } if (target) { - virBufferAddLit(&buf, " <target>\n"); - virBufferAsprintf(&buf, " <path>%s</path>\n", target); - virBufferAddLit(&buf, " </target>\n"); + 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"); - virBufferAsprintf(&buf, " <host name='%s'", host); + 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"); - virBufferAsprintf(&buf, " <iqn name='%s'/>\n", initiator); - virBufferAddLit(&buf, " </initiator>\n"); + 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")); diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index e37a5b3..6beb25a 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -253,7 +253,7 @@ vshParseSnapshotMemspec(vshControl *ctl, virBufferPtr buf, const char *str) goto cleanup; } - virBufferAddLit(buf, " <memory"); + virBufferAddLit(buf, "<memory"); virBufferEscapeString(buf, " snapshot='%s'", snapshot); virBufferEscapeString(buf, " file='%s'", file); virBufferAddLit(buf, "/>\n"); @@ -293,16 +293,18 @@ vshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str) goto cleanup; } - virBufferEscapeString(buf, " <disk name='%s'", name); + virBufferEscapeString(buf, "<disk name='%s'", name); if (snapshot) virBufferAsprintf(buf, " snapshot='%s'", snapshot); if (driver || file) { virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); if (driver) - virBufferAsprintf(buf, " <driver type='%s'/>\n", driver); + virBufferAsprintf(buf, "<driver type='%s'/>\n", driver); if (file) - virBufferEscapeString(buf, " <source file='%s'/>\n", file); - virBufferAddLit(buf, " </disk>\n"); + virBufferEscapeString(buf, "<source file='%s'/>\n", file); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "</disk>\n"); } else { virBufferAddLit(buf, "/>\n"); } @@ -424,8 +426,9 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) goto cleanup; virBufferAddLit(&buf, "<domainsnapshot>\n"); - virBufferEscapeString(&buf, " <name>%s</name>\n", name); - virBufferEscapeString(&buf, " <description>%s</description>\n", desc); + virBufferAdjustIndent(&buf, 2); + virBufferEscapeString(&buf, "<name>%s</name>\n", name); + virBufferEscapeString(&buf, "<description>%s</description>\n", desc); if (vshCommandOptStringReq(ctl, cmd, "memspec", &memspec) < 0) goto cleanup; @@ -434,13 +437,16 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) goto cleanup; if (vshCommandOptBool(cmd, "diskspec")) { - virBufferAddLit(&buf, " <disks>\n"); + virBufferAddLit(&buf, "<disks>\n"); + virBufferAdjustIndent(&buf, 2); while ((opt = vshCommandOptArgv(cmd, opt))) { if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0) goto cleanup; } - virBufferAddLit(&buf, " </disks>\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</disks>\n"); } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</domainsnapshot>\n"); if (virBufferError(&buf)) { diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index d7c4823..9bca421 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -212,15 +212,18 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) goto cleanup; virBufferAddLit(&buf, "<volume>\n"); - virBufferAsprintf(&buf, " <name>%s</name>\n", name); - virBufferAsprintf(&buf, " <capacity>%llu</capacity>\n", capacity); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<name>%s</name>\n", name); + virBufferAsprintf(&buf, "<capacity>%llu</capacity>\n", capacity); if (allocationStr) - virBufferAsprintf(&buf, " <allocation>%llu</allocation>\n", allocation); + virBufferAsprintf(&buf, "<allocation>%llu</allocation>\n", allocation); if (format) { - virBufferAddLit(&buf, " <target>\n"); - virBufferAsprintf(&buf, " <format type='%s'/>\n", format); - virBufferAddLit(&buf, " </target>\n"); + virBufferAddLit(&buf, "<target>\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<format type='%s'/>\n", format); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</target>\n"); } /* Convert the snapshot parameters into backingStore XML */ @@ -272,18 +275,21 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) } /* Create XML for the backing store */ - virBufferAddLit(&buf, " <backingStore>\n"); - virBufferAsprintf(&buf, " <path>%s</path>\n", snapshotStrVolPath); + virBufferAddLit(&buf, "<backingStore>\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<path>%s</path>\n", snapshotStrVolPath); if (snapshotStrFormat) - virBufferAsprintf(&buf, " <format type='%s'/>\n", + virBufferAsprintf(&buf, "<format type='%s'/>\n", snapshotStrFormat); - virBufferAddLit(&buf, " </backingStore>\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</backingStore>\n"); /* Cleanup snapshot allocations */ VIR_FREE(snapshotStrVolPath); virStorageVolFree(snapVol); } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</volume>\n"); if (virBufferError(&buf)) { -- 1.8.5.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list