Callers are still hard-coded, for now. * src/conf/domain_conf.c (virDomainDeviceInfoFormat): Add parameter. Adjust callers. --- src/conf/domain_conf.c | 40 +++++++++++++++++++++------------------- 1 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0a5e50b..4d2e6c3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1619,28 +1619,30 @@ void virDomainDefClearDeviceAliases(virDomainDefPtr def) static int ATTRIBUTE_NONNULL(2) virDomainDeviceInfoFormat(virBufferPtr buf, virDomainDeviceInfoPtr info, + int indent, unsigned int flags) { if (info->alias && !(flags & VIR_DOMAIN_XML_INACTIVE)) { - virBufferAsprintf(buf, " <alias name='%s'/>\n", info->alias); + virBufferAsprintf(buf, "%*s<alias name='%s'/>\n", indent, "", + info->alias); } if (info->mastertype == VIR_DOMAIN_CONTROLLER_MASTER_USB) { - virBufferAsprintf(buf, " <master startport='%d'/>\n", + virBufferAsprintf(buf, "%*s<master startport='%d'/>\n", indent, "", info->master.usb.startport); } if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) return 0; - /* We'll be in domain/devices/[device type]/ so 3 level indent */ - virBufferAsprintf(buf, " <address type='%s'", + virBufferAsprintf(buf, "%*s<address type='%s'", indent, "", virDomainDeviceAddressTypeToString(info->type)); switch (info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x' slot='0x%.2x' function='0x%.1x'", + virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x' slot='0x%.2x'" + " function='0x%.1x'", info->addr.pci.domain, info->addr.pci.bus, info->addr.pci.slot, @@ -9206,7 +9208,7 @@ virDomainDiskDefFormat(virBufferPtr buf, virStorageEncryptionFormat(buf, def->encryption, 6) < 0) return -1; - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </disk>\n"); @@ -9276,7 +9278,7 @@ virDomainControllerDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </controller>\n"); } else { @@ -9340,7 +9342,7 @@ virDomainFSDefFormat(virBufferPtr buf, if (def->readonly) virBufferAddLit(buf, " <readonly/>\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </filesystem>\n"); @@ -9564,7 +9566,7 @@ virDomainNetDefFormat(virBufferPtr buf, if (virBandwidthDefFormat(buf, def->bandwidth, " ") < 0) return -1; - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </interface>\n"); @@ -9756,7 +9758,7 @@ virDomainChrDefFormat(virBufferPtr buf, } if (virDomainDeviceInfoIsSet(&def->info, flags)) { - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; } @@ -9811,7 +9813,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, _("unexpected smartcard type %d"), def->type); return -1; } - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </smartcard>\n"); return 0; @@ -9835,7 +9837,7 @@ virDomainSoundDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </sound>\n"); } else { @@ -9864,7 +9866,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </memballoon>\n"); } else { @@ -9914,7 +9916,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </watchdog>\n"); } else { @@ -9965,7 +9967,7 @@ virDomainVideoDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </video>\n"); @@ -9997,7 +9999,7 @@ virDomainInputDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </input>\n"); } else { @@ -10390,7 +10392,7 @@ virDomainHostdevDefFormat(virBufferPtr buf, if (def->bootIndex) virBufferAsprintf(buf, " <boot order='%d'/>\n", def->bootIndex); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </hostdev>\n"); @@ -10410,7 +10412,7 @@ virDomainRedirdevDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " <redirdev bus='%s'", bus); if (virDomainChrSourceDefFormat(buf, &def->source.chr, false, flags) < 0) return -1; - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </redirdev>\n"); @@ -10434,7 +10436,7 @@ virDomainHubDefFormat(virBufferPtr buf, if (virDomainDeviceInfoIsSet(&def->info, flags)) { virBufferAddLit(buf, ">\n"); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, 6, flags) < 0) return -1; virBufferAddLit(buf, " </hub>\n"); } else { -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list