[PATCH v5 08/13] qemu: Add zPCI address definition check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We should ensure that the Qemu should support zPCI when zPCI address is
defined in XML. Otherwise the error should be reported. So this patch
introduces the validation of zPCI address definition for
qemuDomainDeviceDefValidate().

Signed-off-by: Yi Min Zhao <zyimin@xxxxxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index aebd58c49c..7d7cd3cfdc 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5728,6 +5728,27 @@ qemuDomainDeviceDefValidateGraphics(const virDomainGraphicsDef *graphics,
 }
 
 
+static int
+qemuDomainZPCIAddressDefValidate(virDomainDeviceDef *dev,
+                                     virQEMUCapsPtr qemuCaps)
+{
+    virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
+
+    if (!info || (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI))
+        return 0;
+
+    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
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def,
@@ -5741,6 +5762,10 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                                             def->emulator)))
         return -1;
 
+    ret = qemuDomainZPCIAddressDefValidate((virDomainDeviceDef *)dev, qemuCaps);
+    if (ret < 0)
+        goto out;
+
     switch ((virDomainDeviceType)dev->type) {
     case VIR_DOMAIN_DEVICE_NET:
         ret = qemuDomainDeviceDefValidateNetwork(dev->data.net);
@@ -5813,6 +5838,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         break;
     }
 
+ out:
     virObjectUnref(qemuCaps);
     return ret;
 }
-- 
Yi Min

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux