We should ensure that the QEMU should support zPCI when zPCI address is
defined in XML. Otherwise the error should be reported. This patch
introduces a generic validation function
qemuDomainDeviceDefValidateAddress() which calls
qemuDomainDeviceDefValidateZPCIAddress() if address type is PCI
address.
Signed-off-by: Yi Min Zhao <zyimin(a)linux.ibm.com>
---
src/qemu/qemu_domain.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fa9113e542..94a14c582b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5798,6 +5798,39 @@ qemuDomainDeviceDefValidateInput(const virDomainInputDef *input,
}
+static int
+qemuDomainDeviceDefValidateZPCIAddress(virDomainDeviceInfoPtr info,
+ virQEMUCapsPtr qemuCaps)
+{
+ if (!virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci) &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s",
+ _("This QEMU binary doesn't support zPCI"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int
+qemuDomainDeviceDefValidateAddress(const virDomainDeviceDef *dev,
+ virQEMUCapsPtr qemuCaps)
+{
+ virDomainDeviceInfoPtr info =
+ virDomainDeviceGetInfo((virDomainDeviceDef *)dev);
+
+ if (!info)
+ return 0;
+
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)
+ return qemuDomainDeviceDefValidateZPCIAddress(info, qemuCaps);
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
@@ -5811,6 +5844,10 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
def->emulator)))
return -1;
+ ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps);
+ if (ret < 0)
+ goto out;
+
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_NET:
ret = qemuDomainDeviceDefValidateNetwork(dev->data.net);
@@ -5886,6 +5923,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
}
+ out:
virObjectUnref(qemuCaps);
return ret;
}
--
Yi Min