[PATCH 09/11] qemu: Use @parseOpaque in qemuDomainDefValidate

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

 



Since the previous commit made sure that @parseOpaque is always set to
a non-NULL value we can use it now.

This avoids the usage of a possible different QEMU capability than
before, since virQEMUCapsCacheLookup could return a different QEMU
capability than used before (e.g. if during the job the used QEMU
binary has been replaced and thus the QEMU capability is invalidated
by the file cache)

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 44 ++++++++++++++++--------------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 52d2aa435a36..aacb54a72f72 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3990,21 +3990,15 @@ qemuDomainDefValidateMemory(const virDomainDef *def)
 static int
 qemuDomainDefValidate(const virDomainDef *def,
                       virCapsPtr caps ATTRIBUTE_UNUSED,
-                      void *opaque,
-                      void *parseOpaque ATTRIBUTE_UNUSED)
+                      void *opaque ATTRIBUTE_UNUSED,
+                      void *parseOpaque)
 {
-    virQEMUDriverPtr driver = opaque;
-    virQEMUCapsPtr qemuCaps = NULL;
-    int ret = -1;
-
-    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
-                                            def->emulator)))
-        goto cleanup;
+    virQEMUCapsPtr qemuCaps = parseOpaque;
 
     if (def->mem.min_guarantee) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Parameter 'min_guarantee' not supported by QEMU."));
-        goto cleanup;
+        return -1;
     }
 
     /* On x86, UEFI requires ACPI */
@@ -4014,7 +4008,7 @@ qemuDomainDefValidate(const virDomainDef *def,
         def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("UEFI requires ACPI on this architecture"));
-        goto cleanup;
+        return -1;
     }
 
     /* On aarch64, ACPI requires UEFI */
@@ -4024,7 +4018,7 @@ qemuDomainDefValidate(const virDomainDef *def,
          def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("ACPI requires UEFI on this architecture"));
-        goto cleanup;
+        return -1;
     }
 
     if (def->os.loader &&
@@ -4035,7 +4029,7 @@ qemuDomainDefValidate(const virDomainDef *def,
         if (!qemuDomainIsQ35(def)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("Secure boot is supported with q35 machine types only"));
-            goto cleanup;
+            return -1;
         }
 
         /* Now, technically it is possible to have secure boot on
@@ -4044,13 +4038,13 @@ qemuDomainDefValidate(const virDomainDef *def,
         if (def->os.arch != VIR_ARCH_X86_64) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("Secure boot is supported for x86_64 architecture only"));
-            goto cleanup;
+            return -1;
         }
 
         if (def->features[VIR_DOMAIN_FEATURE_SMM] != VIR_TRISTATE_SWITCH_ON) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("Secure boot requires SMM feature enabled"));
-            goto cleanup;
+            return -1;
         }
     }
 
@@ -4068,7 +4062,7 @@ qemuDomainDefValidate(const virDomainDef *def,
             topologycpus != virDomainDefGetVcpusMax(def)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("CPU topology doesn't match maximum vcpu count"));
-            goto cleanup;
+            return -1;
         }
 
         /* vCPU hotplug granularity must be respected */
@@ -4078,7 +4072,7 @@ qemuDomainDefValidate(const virDomainDef *def,
                            _("vCPUs count must be a multiple of the vCPU "
                              "hotplug granularity (%u)"),
                            granularity);
-            goto cleanup;
+            return -1;
         }
     }
 
@@ -4089,14 +4083,14 @@ qemuDomainDefValidate(const virDomainDef *def,
                            _("more than %d vCPUs are only supported on "
                              "q35-based machine types"),
                            QEMU_MAX_VCPUS_WITHOUT_EIM);
-            goto cleanup;
+            return -1;
         }
         if (!def->iommu || def->iommu->eim != VIR_TRISTATE_SWITCH_ON) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("more than %d vCPUs require extended interrupt "
                              "mode enabled on the iommu device"),
                            QEMU_MAX_VCPUS_WITHOUT_EIM);
-            goto cleanup;
+            return -1;
         }
     }
 
@@ -4104,20 +4098,16 @@ qemuDomainDefValidate(const virDomainDef *def,
         def->virtType != VIR_DOMAIN_VIRT_KVM) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("cachetune is only supported for KVM domains"));
-        goto cleanup;
+        return -1;
     }
 
     if (qemuDomainDefValidateFeatures(def, qemuCaps) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuDomainDefValidateMemory(def) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    virObjectUnref(qemuCaps);
-    return ret;
+    return 0;
 }
 
 
-- 
2.17.0

--
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