[PATCH 1/5] qemu: Validate RNG model

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

 



The aim is to eliminate virDomainCapsDeviceDefValidate(). And in
order to do so, the domain RNG model has to be validated in
qemuValidateDomainRNGDef().

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_capabilities.c | 18 +-----------------
 src/qemu/qemu_validate.c       | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 6ee8730111..b886ba7090 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -640,20 +640,6 @@ virDomainCapsFormat(const virDomainCaps *caps)
     } while (0)
 
 
-static int
-virDomainCapsDeviceRNGDefValidate(const virDomainCaps *caps,
-                                  const virDomainRNGDef *dev)
-{
-    if (ENUM_VALUE_MISSING(caps->rng.model, dev->model)) {
-        ENUM_VALUE_ERROR("rng model",
-                         virDomainRNGModelTypeToString(dev->model));
-        return -1;
-    }
-
-    return 0;
-}
-
-
 static int
 virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps,
                                     const virDomainVideoDef *dev)
@@ -676,9 +662,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
     int ret = 0;
 
     switch ((virDomainDeviceType) dev->type) {
-    case VIR_DOMAIN_DEVICE_RNG:
-        ret = virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng);
-        break;
     case VIR_DOMAIN_DEVICE_VIDEO:
         ret = virDomainCapsDeviceVideoDefValidate(caps, dev->data.video);
         break;
@@ -706,6 +689,7 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *caps,
     case VIR_DOMAIN_DEVICE_HUB:
     case VIR_DOMAIN_DEVICE_MEMBALLOON:
     case VIR_DOMAIN_DEVICE_NVRAM:
+    case VIR_DOMAIN_DEVICE_RNG:
     case VIR_DOMAIN_DEVICE_TPM:
     case VIR_DOMAIN_DEVICE_PANIC:
     case VIR_DOMAIN_DEVICE_IOMMU:
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 79e765a212..c18865367e 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1883,6 +1883,31 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def,
         return -1;
     }
 
+    switch ((virDomainRNGModel) def->model) {
+    case VIR_DOMAIN_RNG_MODEL_VIRTIO:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("domain configuration does not support rng model '%s'"),
+                           virDomainRNGModelTypeToString(def->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL:
+    case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("domain configuration does not support rng model '%s'"),
+                           virDomainRNGModelTypeToString(def->model));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_RNG_MODEL_LAST:
+        break;
+    }
+
     if (qemuValidateDomainVirtioOptions(def->virtio, qemuCaps) < 0)
         return -1;
 
-- 
2.26.2




[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