[PATCH 03/15] qemu: move qemuDomainValidateDef() to qemu_validate.c

Daniel Henrique Barboza danielhb413 at gmail.com
Thu Mar 26 21:31:13 UTC 2020


After moving most of static functions qemuDomainValidateDef() uses,
move the last remaining static and qemuDomainValidateDef() itself
to qemu_validation.c.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_domain.c   | 254 +-----------------------------------
 src/qemu/qemu_validate.c | 269 +++++++++++++++++++++++++++++++++++++--
 src/qemu/qemu_validate.h |  19 +--
 3 files changed, 263 insertions(+), 279 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 413ce4a2dc..84212f7441 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5007,39 +5007,6 @@ qemuDomainDefPostParse(virDomainDefPtr def,
 }
 
 
-/**
- * qemuDomainDefGetVcpuHotplugGranularity:
- * @def: domain definition
- *
- * With QEMU 2.7 and newer, vCPUs can only be hotplugged in groups that
- * respect the guest's hotplug granularity; because of that, QEMU will
- * not allow guests to start unless the initial number of vCPUs is a
- * multiple of the hotplug granularity.
- *
- * Returns the vCPU hotplug granularity.
- */
-static unsigned int
-qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
-{
-    /* If the guest CPU topology has not been configured, assume we
-     * can hotplug vCPUs one at a time */
-    if (!def->cpu || def->cpu->sockets == 0)
-        return 1;
-
-    /* For pSeries guests, hotplug can only be performed one core
-     * at a time, so the vCPU hotplug granularity is the number
-     * of threads per core */
-    if (qemuDomainIsPSeries(def))
-        return def->cpu->threads;
-
-    /* In all other cases, we can hotplug vCPUs one at a time */
-    return 1;
-}
-
-
-#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
-
-
 static int
 qemuDomainDeviceDefValidateNVRAM(virDomainNVRAMDefPtr nvram,
                                  const virDomainDef *def,
@@ -5182,225 +5149,6 @@ qemuDomainDeviceDefValidateMemory(virDomainMemoryDefPtr mem,
     return 0;
 }
 
-static int
-qemuDomainDefValidate(const virDomainDef *def,
-                      void *opaque)
-{
-    virQEMUDriverPtr driver = opaque;
-    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
-    g_autoptr(virQEMUCaps) qemuCaps = NULL;
-    size_t i;
-
-    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
-                                            def->emulator)))
-        return -1;
-
-    if (def->os.type != VIR_DOMAIN_OSTYPE_HVM) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Emulator '%s' does not support os type '%s'"),
-                       def->emulator, virDomainOSTypeToString(def->os.type));
-        return -1;
-    }
-
-    if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Emulator '%s' does not support arch '%s'"),
-                       def->emulator, virArchToString(def->os.arch));
-        return -1;
-    }
-
-    if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Emulator '%s' does not support virt type '%s'"),
-                       def->emulator, virDomainVirtTypeToString(def->virtType));
-        return -1;
-    }
-
-    if (qemuCaps &&
-        !virQEMUCapsIsMachineSupported(qemuCaps, def->virtType, def->os.machine)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Emulator '%s' does not support machine type '%s'"),
-                       def->emulator, def->os.machine);
-        return -1;
-    }
-
-    if (def->mem.min_guarantee) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Parameter 'min_guarantee' not supported by QEMU."));
-        return -1;
-    }
-
-    /* On x86, UEFI requires ACPI */
-    if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
-         virDomainDefHasOldStyleUEFI(def)) &&
-        ARCH_IS_X86(def->os.arch) &&
-        def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("UEFI requires ACPI on this architecture"));
-        return -1;
-    }
-
-    /* On aarch64, ACPI requires UEFI */
-    if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
-        def->os.arch == VIR_ARCH_AARCH64 &&
-        (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
-         !virDomainDefHasOldStyleUEFI(def))) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("ACPI requires UEFI on this architecture"));
-        return -1;
-    }
-
-    if (def->os.loader &&
-        def->os.loader->secure == VIR_TRISTATE_BOOL_YES) {
-        /* These are the QEMU implementation limitations. But we
-         * have to live with them for now. */
-
-        if (!qemuDomainIsQ35(def)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Secure boot is supported with q35 machine types only"));
-            return -1;
-        }
-
-        /* Now, technically it is possible to have secure boot on
-         * 32bits too, but that would require some -cpu xxx magic
-         * too. Not worth it unless we are explicitly asked. */
-        if (def->os.arch != VIR_ARCH_X86_64) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Secure boot is supported for x86_64 architecture only"));
-            return -1;
-        }
-
-        /* SMM will be enabled by qemuFirmwareFillDomain() if needed. */
-        if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE &&
-            def->features[VIR_DOMAIN_FEATURE_SMM] != VIR_TRISTATE_SWITCH_ON) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Secure boot requires SMM feature enabled"));
-            return -1;
-        }
-    }
-
-    if (def->genidRequested &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("this QEMU does not support the 'genid' capability"));
-        return -1;
-    }
-
-    /* Serial graphics adapter */
-    if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("qemu does not support SGA"));
-            return -1;
-        }
-        if (!def->nserials) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("need at least one serial port to use SGA"));
-            return -1;
-        }
-    }
-
-    if (qemuValidateDomainDefClockTimers(def, qemuCaps) < 0)
-        return -1;
-
-    if (qemuValidateDomainDefPM(def, qemuCaps) < 0)
-        return -1;
-
-    if (qemuValidateDomainDefBoot(def, qemuCaps) < 0)
-        return -1;
-
-    /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus)
-     * enforces stricter rules than previous versions when it comes to guest
-     * CPU topology. Verify known constraints are respected */
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {
-        unsigned int topologycpus;
-        unsigned int granularity;
-        unsigned int numacpus;
-
-        /* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
-         * must agree. We only actually enforce this with QEMU 2.7+, due
-         * to the capability check above */
-        if (virDomainDefGetVcpusTopology(def, &topologycpus) == 0) {
-            if (topologycpus != virDomainDefGetVcpusMax(def)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("CPU topology doesn't match maximum vcpu count"));
-                return -1;
-            }
-
-            numacpus = virDomainNumaGetCPUCountTotal(def->numa);
-            if ((numacpus != 0) && (topologycpus != numacpus)) {
-                VIR_WARN("CPU topology doesn't match numa CPU count; "
-                         "partial NUMA mapping is obsoleted and will "
-                         "be removed in future");
-            }
-        }
-
-        /* vCPU hotplug granularity must be respected */
-        granularity = qemuDomainDefGetVcpuHotplugGranularity(def);
-        if ((virDomainDefGetVcpus(def) % granularity) != 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("vCPUs count must be a multiple of the vCPU "
-                             "hotplug granularity (%u)"),
-                           granularity);
-            return -1;
-        }
-    }
-
-    if (qemuValidateDomainCpuCount(def, qemuCaps) < 0)
-        return -1;
-
-    if (ARCH_IS_X86(def->os.arch) &&
-        virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
-        if (!qemuDomainIsQ35(def)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("more than %d vCPUs are only supported on "
-                             "q35-based machine types"),
-                           QEMU_MAX_VCPUS_WITHOUT_EIM);
-            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);
-            return -1;
-        }
-    }
-
-    if (def->nresctrls &&
-        def->virtType != VIR_DOMAIN_VIRT_KVM) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("cachetune is only supported for KVM domains"));
-        return -1;
-    }
-
-    if (qemuValidateDomainDefFeatures(def, qemuCaps) < 0)
-        return -1;
-
-    if (qemuValidateDomainDefMemory(def, qemuCaps) < 0)
-        return -1;
-
-    if (qemuValidateDomainDefNuma(def, qemuCaps) < 0)
-        return -1;
-
-    if (qemuValidateDomainDefConsole(def, qemuCaps) < 0)
-        return -1;
-
-    if (cfg->vncTLS && cfg->vncTLSx509secretUUID &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_TLS_CREDS_X509)) {
-        for (i = 0; i < def->ngraphics; i++) {
-            if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("encrypted VNC TLS keys are not supported with "
-                                 "this QEMU binary"));
-                return -1;
-            }
-        }
-    }
-
-    return 0;
-}
-
 
 static bool
 qemuDomainNetSupportsCoalesce(virDomainNetType type)
@@ -8919,7 +8667,7 @@ virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
     .devicesPostParseCallback = qemuDomainDeviceDefPostParse,
     .domainPostParseCallback = qemuDomainDefPostParse,
     .assignAddressesCallback = qemuDomainDefAssignAddresses,
-    .domainValidateCallback = qemuDomainDefValidate,
+    .domainValidateCallback = qemuValidateDomainDef,
     .deviceValidateCallback = qemuDomainDeviceDefValidate,
 
     .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index b2a8c3c0b5..27e0558770 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -22,9 +22,13 @@
 
 #include "qemu_validate.h"
 #include "qemu_domain.h"
+#include "virlog.h"
 #include "virutil.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
+#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
+
+VIR_LOG_INIT("qemu.qemu_validate");
 
 
 static int
@@ -136,7 +140,7 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefFeatures(const virDomainDef *def,
                               virQEMUCapsPtr qemuCaps)
 {
@@ -311,7 +315,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefClockTimers(const virDomainDef *def,
                                  virQEMUCapsPtr qemuCaps)
 {
@@ -449,7 +453,7 @@ qemuValidateDomainDefClockTimers(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefPM(const virDomainDef *def,
                         virQEMUCapsPtr qemuCaps)
 {
@@ -481,7 +485,7 @@ qemuValidateDomainDefPM(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefBoot(const virDomainDef *def,
                           virQEMUCapsPtr qemuCaps)
 {
@@ -507,7 +511,7 @@ qemuValidateDomainDefBoot(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainCpuCount(const virDomainDef *def, virQEMUCapsPtr qemuCaps)
 {
     unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->virtType,
@@ -530,7 +534,7 @@ qemuValidateDomainCpuCount(const virDomainDef *def, virQEMUCapsPtr qemuCaps)
 }
 
 
-int
+static int
 qemuValidateDomainDefMemory(const virDomainDef *def,
                             virQEMUCapsPtr qemuCaps)
 {
@@ -585,7 +589,7 @@ qemuValidateDomainDefMemory(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefNuma(const virDomainDef *def,
                           virQEMUCapsPtr qemuCaps)
 {
@@ -648,7 +652,7 @@ qemuValidateDomainDefNuma(const virDomainDef *def,
 }
 
 
-int
+static int
 qemuValidateDomainDefConsole(const virDomainDef *def,
                              virQEMUCapsPtr qemuCaps)
 {
@@ -689,3 +693,252 @@ qemuValidateDomainDefConsole(const virDomainDef *def,
 
     return 0;
 }
+
+
+/**
+ * qemuValidateDefGetVcpuHotplugGranularity:
+ * @def: domain definition
+ *
+ * With QEMU 2.7 and newer, vCPUs can only be hotplugged in groups that
+ * respect the guest's hotplug granularity; because of that, QEMU will
+ * not allow guests to start unless the initial number of vCPUs is a
+ * multiple of the hotplug granularity.
+ *
+ * Returns the vCPU hotplug granularity.
+ */
+static unsigned int
+qemuValidateDefGetVcpuHotplugGranularity(const virDomainDef *def)
+{
+    /* If the guest CPU topology has not been configured, assume we
+     * can hotplug vCPUs one at a time */
+    if (!def->cpu || def->cpu->sockets == 0)
+        return 1;
+
+    /* For pSeries guests, hotplug can only be performed one core
+     * at a time, so the vCPU hotplug granularity is the number
+     * of threads per core */
+    if (qemuDomainIsPSeries(def))
+        return def->cpu->threads;
+
+    /* In all other cases, we can hotplug vCPUs one at a time */
+    return 1;
+}
+
+
+int
+qemuValidateDomainDef(const virDomainDef *def, void *opaque)
+{
+    virQEMUDriverPtr driver = opaque;
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+    g_autoptr(virQEMUCaps) qemuCaps = NULL;
+    size_t i;
+
+    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
+                                            def->emulator)))
+        return -1;
+
+    if (def->os.type != VIR_DOMAIN_OSTYPE_HVM) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Emulator '%s' does not support os type '%s'"),
+                       def->emulator, virDomainOSTypeToString(def->os.type));
+        return -1;
+    }
+
+    if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Emulator '%s' does not support arch '%s'"),
+                       def->emulator, virArchToString(def->os.arch));
+        return -1;
+    }
+
+    if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Emulator '%s' does not support virt type '%s'"),
+                       def->emulator, virDomainVirtTypeToString(def->virtType));
+        return -1;
+    }
+
+    if (qemuCaps &&
+        !virQEMUCapsIsMachineSupported(qemuCaps, def->virtType, def->os.machine)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Emulator '%s' does not support machine type '%s'"),
+                       def->emulator, def->os.machine);
+        return -1;
+    }
+
+    if (def->mem.min_guarantee) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Parameter 'min_guarantee' not supported by QEMU."));
+        return -1;
+    }
+
+    /* On x86, UEFI requires ACPI */
+    if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
+         virDomainDefHasOldStyleUEFI(def)) &&
+        ARCH_IS_X86(def->os.arch) &&
+        def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("UEFI requires ACPI on this architecture"));
+        return -1;
+    }
+
+    /* On aarch64, ACPI requires UEFI */
+    if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
+        def->os.arch == VIR_ARCH_AARCH64 &&
+        (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
+         !virDomainDefHasOldStyleUEFI(def))) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("ACPI requires UEFI on this architecture"));
+        return -1;
+    }
+
+    if (def->os.loader &&
+        def->os.loader->secure == VIR_TRISTATE_BOOL_YES) {
+        /* These are the QEMU implementation limitations. But we
+         * have to live with them for now. */
+
+        if (!qemuDomainIsQ35(def)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Secure boot is supported with q35 machine types only"));
+            return -1;
+        }
+
+        /* Now, technically it is possible to have secure boot on
+         * 32bits too, but that would require some -cpu xxx magic
+         * too. Not worth it unless we are explicitly asked. */
+        if (def->os.arch != VIR_ARCH_X86_64) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Secure boot is supported for x86_64 architecture only"));
+            return -1;
+        }
+
+        /* SMM will be enabled by qemuFirmwareFillDomain() if needed. */
+        if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE &&
+            def->features[VIR_DOMAIN_FEATURE_SMM] != VIR_TRISTATE_SWITCH_ON) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Secure boot requires SMM feature enabled"));
+            return -1;
+        }
+    }
+
+    if (def->genidRequested &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("this QEMU does not support the 'genid' capability"));
+        return -1;
+    }
+
+    /* Serial graphics adapter */
+    if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("qemu does not support SGA"));
+            return -1;
+        }
+        if (!def->nserials) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("need at least one serial port to use SGA"));
+            return -1;
+        }
+    }
+
+    if (qemuValidateDomainDefClockTimers(def, qemuCaps) < 0)
+        return -1;
+
+    if (qemuValidateDomainDefPM(def, qemuCaps) < 0)
+        return -1;
+
+    if (qemuValidateDomainDefBoot(def, qemuCaps) < 0)
+        return -1;
+
+    /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus)
+     * enforces stricter rules than previous versions when it comes to guest
+     * CPU topology. Verify known constraints are respected */
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {
+        unsigned int topologycpus;
+        unsigned int granularity;
+        unsigned int numacpus;
+
+        /* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
+         * must agree. We only actually enforce this with QEMU 2.7+, due
+         * to the capability check above */
+        if (virDomainDefGetVcpusTopology(def, &topologycpus) == 0) {
+            if (topologycpus != virDomainDefGetVcpusMax(def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("CPU topology doesn't match maximum vcpu count"));
+                return -1;
+            }
+
+            numacpus = virDomainNumaGetCPUCountTotal(def->numa);
+            if ((numacpus != 0) && (topologycpus != numacpus)) {
+                VIR_WARN("CPU topology doesn't match numa CPU count; "
+                         "partial NUMA mapping is obsoleted and will "
+                         "be removed in future");
+            }
+        }
+
+        /* vCPU hotplug granularity must be respected */
+        granularity = qemuValidateDefGetVcpuHotplugGranularity(def);
+        if ((virDomainDefGetVcpus(def) % granularity) != 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("vCPUs count must be a multiple of the vCPU "
+                             "hotplug granularity (%u)"),
+                           granularity);
+            return -1;
+        }
+    }
+
+    if (qemuValidateDomainCpuCount(def, qemuCaps) < 0)
+        return -1;
+
+    if (ARCH_IS_X86(def->os.arch) &&
+        virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
+        if (!qemuDomainIsQ35(def)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("more than %d vCPUs are only supported on "
+                             "q35-based machine types"),
+                           QEMU_MAX_VCPUS_WITHOUT_EIM);
+            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);
+            return -1;
+        }
+    }
+
+    if (def->nresctrls &&
+        def->virtType != VIR_DOMAIN_VIRT_KVM) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("cachetune is only supported for KVM domains"));
+        return -1;
+    }
+
+    if (qemuValidateDomainDefFeatures(def, qemuCaps) < 0)
+        return -1;
+
+    if (qemuValidateDomainDefMemory(def, qemuCaps) < 0)
+        return -1;
+
+    if (qemuValidateDomainDefNuma(def, qemuCaps) < 0)
+        return -1;
+
+    if (qemuValidateDomainDefConsole(def, qemuCaps) < 0)
+        return -1;
+
+    if (cfg->vncTLS && cfg->vncTLSx509secretUUID &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_TLS_CREDS_X509)) {
+        for (i = 0; i < def->ngraphics; i++) {
+            if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("encrypted VNC TLS keys are not supported with "
+                                 "this QEMU binary"));
+                return -1;
+            }
+        }
+    }
+
+    return 0;
+}
diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h
index 85d1bc07cb..b6a6466a24 100644
--- a/src/qemu/qemu_validate.h
+++ b/src/qemu/qemu_validate.h
@@ -25,21 +25,4 @@
 #include "domain_conf.h"
 #include "qemu_capabilities.h"
 
-int qemuValidateDomainDefFeatures(const virDomainDef *def,
-                                  virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefClockTimers(const virDomainDef *def,
-                                     virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefPM(const virDomainDef *def,
-                            virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefBoot(const virDomainDef *def,
-                              virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainCpuCount(const virDomainDef *def,
-                               virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainCpuCount(const virDomainDef *def,
-                               virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefMemory(const virDomainDef *def,
-                                virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefNuma(const virDomainDef *def,
-                              virQEMUCapsPtr qemuCaps);
-int qemuValidateDomainDefConsole(const virDomainDef *def,
-                                 virQEMUCapsPtr qemuCaps);
+int qemuValidateDomainDef(const virDomainDef *def, void *opaque);
-- 
2.25.1





More information about the libvir-list mailing list