qemu: domain: Validate that machine type is supported by qemu

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-01-22 10:06:53 +01:00
parent cb5a89c115
commit 0b9d1a8073
3 changed files with 13 additions and 1 deletions

View File

@ -2701,7 +2701,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
}
static bool
bool
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
virDomainVirtType virtType,
const char *canonical_machine)

View File

@ -631,6 +631,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);

View File

@ -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."));