|
|
c480ed |
From 2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <2566a32fae64fa5cc8a3d3c30778d0ea7d8c4faa@dist-git>
|
|
|
c480ed |
From: Yi Min Zhao <zyimin@linux.ibm.com>
|
|
|
c480ed |
Date: Mon, 8 Apr 2019 10:57:24 +0200
|
|
|
c480ed |
Subject: [PATCH] conf: use virXMLFormatElement() in
|
|
|
c480ed |
virDomainDeviceInfoFormat()
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
In order to add zPCI child element for PCI address, we update
|
|
|
c480ed |
virDomainDeviceInfoFormat() to format device info by helper function
|
|
|
c480ed |
virXMLFormatElement(). Then we could simply format zPCI address into
|
|
|
c480ed |
child buffer later.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
|
|
|
c480ed |
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
c480ed |
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
c480ed |
|
|
|
c480ed |
(cherry picked from commit 0d6b87335c00451b0923ecc91d617f71e4135bf8)
|
|
|
c480ed |
|
|
|
c480ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1508149
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
c480ed |
Message-Id: <20190408085732.28684-8-abologna@redhat.com>
|
|
|
c480ed |
Reviewed-by: Laine Stump <laine@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/conf/domain_conf.c | 40 ++++++++++++++++++++++------------------
|
|
|
c480ed |
1 file changed, 22 insertions(+), 18 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
c480ed |
index e62f78471c..bcb0558bc3 100644
|
|
|
c480ed |
--- a/src/conf/domain_conf.c
|
|
|
c480ed |
+++ b/src/conf/domain_conf.c
|
|
|
c480ed |
@@ -6447,6 +6447,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
virDomainDeviceInfoPtr info,
|
|
|
c480ed |
unsigned int flags)
|
|
|
c480ed |
{
|
|
|
c480ed |
+ virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
|
|
|
c480ed |
+
|
|
|
c480ed |
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) {
|
|
|
c480ed |
virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex);
|
|
|
c480ed |
|
|
|
c480ed |
@@ -6491,13 +6493,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
|
|
|
c480ed |
return;
|
|
|
c480ed |
|
|
|
c480ed |
- virBufferAsprintf(buf, "
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " type='%s'",
|
|
|
c480ed |
virDomainDeviceAddressTypeToString(info->type));
|
|
|
c480ed |
|
|
|
c480ed |
switch ((virDomainDeviceAddressType) info->type) {
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
|
|
|
c480ed |
if (!virPCIDeviceAddressIsEmpty(&info->addr.pci)) {
|
|
|
c480ed |
- virBufferAsprintf(buf, " domain='0x%.4x' bus='0x%.2x' "
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " domain='0x%.4x' bus='0x%.2x' "
|
|
|
c480ed |
"slot='0x%.2x' function='0x%.1x'",
|
|
|
c480ed |
info->addr.pci.domain,
|
|
|
c480ed |
info->addr.pci.bus,
|
|
|
c480ed |
@@ -6505,13 +6507,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
info->addr.pci.function);
|
|
|
c480ed |
}
|
|
|
c480ed |
if (info->addr.pci.multi) {
|
|
|
c480ed |
- virBufferAsprintf(buf, " multifunction='%s'",
|
|
|
c480ed |
- virTristateSwitchTypeToString(info->addr.pci.multi));
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " multifunction='%s'",
|
|
|
c480ed |
+ virTristateSwitchTypeToString(info->addr.pci.multi));
|
|
|
c480ed |
}
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
|
|
|
c480ed |
- virBufferAsprintf(buf, " controller='%d' bus='%d' target='%d' unit='%d'",
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' target='%d' unit='%d'",
|
|
|
c480ed |
info->addr.drive.controller,
|
|
|
c480ed |
info->addr.drive.bus,
|
|
|
c480ed |
info->addr.drive.target,
|
|
|
c480ed |
@@ -6519,34 +6521,34 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
|
|
|
c480ed |
- virBufferAsprintf(buf, " controller='%d' bus='%d' port='%d'",
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " controller='%d' bus='%d' port='%d'",
|
|
|
c480ed |
info->addr.vioserial.controller,
|
|
|
c480ed |
info->addr.vioserial.bus,
|
|
|
c480ed |
info->addr.vioserial.port);
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
|
|
|
c480ed |
- virBufferAsprintf(buf, " controller='%d' slot='%d'",
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " controller='%d' slot='%d'",
|
|
|
c480ed |
info->addr.ccid.controller,
|
|
|
c480ed |
info->addr.ccid.slot);
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
|
|
|
c480ed |
- virBufferAsprintf(buf, " bus='%d'", info->addr.usb.bus);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " bus='%d'", info->addr.usb.bus);
|
|
|
c480ed |
if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) {
|
|
|
c480ed |
- virBufferAddLit(buf, " port='");
|
|
|
c480ed |
- virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port);
|
|
|
c480ed |
- virBufferAddLit(buf, "'");
|
|
|
c480ed |
+ virBufferAddLit(&attrBuf, " port='");
|
|
|
c480ed |
+ virDomainUSBAddressPortFormatBuf(&attrBuf, info->addr.usb.port);
|
|
|
c480ed |
+ virBufferAddLit(&attrBuf, "'");
|
|
|
c480ed |
}
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
|
|
|
c480ed |
if (info->addr.spaprvio.has_reg)
|
|
|
c480ed |
- virBufferAsprintf(buf, " reg='0x%llx'", info->addr.spaprvio.reg);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " reg='0x%llx'", info->addr.spaprvio.reg);
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
|
|
|
c480ed |
- virBufferAsprintf(buf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " cssid='0x%x' ssid='0x%x' devno='0x%04x'",
|
|
|
c480ed |
info->addr.ccw.cssid,
|
|
|
c480ed |
info->addr.ccw.ssid,
|
|
|
c480ed |
info->addr.ccw.devno);
|
|
|
c480ed |
@@ -6557,15 +6559,15 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
|
|
|
c480ed |
if (info->addr.isa.iobase > 0)
|
|
|
c480ed |
- virBufferAsprintf(buf, " iobase='0x%x'", info->addr.isa.iobase);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " iobase='0x%x'", info->addr.isa.iobase);
|
|
|
c480ed |
if (info->addr.isa.irq > 0)
|
|
|
c480ed |
- virBufferAsprintf(buf, " irq='0x%x'", info->addr.isa.irq);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " irq='0x%x'", info->addr.isa.irq);
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
|
|
|
c480ed |
- virBufferAsprintf(buf, " slot='%u'", info->addr.dimm.slot);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " slot='%u'", info->addr.dimm.slot);
|
|
|
c480ed |
if (info->addr.dimm.base)
|
|
|
c480ed |
- virBufferAsprintf(buf, " base='0x%llx'", info->addr.dimm.base);
|
|
|
c480ed |
+ virBufferAsprintf(&attrBuf, " base='0x%llx'", info->addr.dimm.base);
|
|
|
c480ed |
|
|
|
c480ed |
break;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -6575,7 +6577,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
|
|
|
c480ed |
break;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- virBufferAddLit(buf, "/>\n");
|
|
|
c480ed |
+ virXMLFormatElement(buf, "address", &attrBuf, NULL);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ virBufferFreeAndReset(&attrBuf);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|