mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
qemuDomainDefPostParse: Fail if unable to fill machine type
Previously, we used virCapabilitiesDomainDataLookup() to fill machine type in post parse callback if none was provided in the domain XML. If machine type couldn't be filled in an error was reported. After4a4132b462we've changed it to virQEMUCapsGetPreferredMachine() which returns NULL, but we no longer report an error and proceed with the post parse callbacks processing. This may lead to a crash because the code later on assumes def->os.machine is not NULL. Fixes:4a4132b462Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Pavel Mores <pmores@redhat.com>
This commit is contained in:
@@ -4973,6 +4973,14 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
||||
if (!def->os.machine) {
|
||||
const char *machine = virQEMUCapsGetPreferredMachine(qemuCaps,
|
||||
def->virtType);
|
||||
if (!machine) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("could not get preferred machine for %s type=%s"),
|
||||
def->emulator,
|
||||
virDomainVirtTypeToString(def->virtType));
|
||||
return -1;
|
||||
}
|
||||
|
||||
def->os.machine = g_strdup(machine);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user