Every supported qemu is able to return the list of machine types it
supports so we can start validating it against that list. The advantage
is a better error message, and the change will also prevent having stale
test data.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_capabilities.h | 4 ++++
src/qemu/qemu_domain.c | 8 ++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 498348ad58..bfbafd04e4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2583,7 +2583,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
}
-static bool
+bool
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
virDomainVirtType virtType,
const char *canonical_machine)
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ebcb0d1373..b66bdad992 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -617,6 +617,10 @@ bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
virDomainVirtType virtType,
const char *name);
+bool virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
+ const char *canonical_machine)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
virDomainVirtType virtType,
const char *name);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ce0c5b78cd..336b34ee67 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5727,6 +5727,14 @@ qemuDomainDefValidate(const virDomainDef *def,
goto cleanup;
}
+ 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);
+ goto cleanup;
+ }
+
if (def->mem.min_guarantee) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Parameter 'min_guarantee' not supported by
QEMU."));
--
2.24.1