mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Simplify and fix qemudCanonicalizeMachine()
The algorithm is quite simple: If the emulator matches a guest's domain: if domain has machine type info: check the domain's machine type info else check the guest's default machine type info else if the emulator matches the guest's default emulator: check the guest's default machine type info The previous implementation was incorrectly falling back to the default machine type info if the domain's machine type info didn't have an alias. * src/qemu_driver.c: simplify and fix qemudCanonicalizeMachine()
This commit is contained in:
parent
3e14a8dc80
commit
6ab16aaf63
@ -4789,30 +4789,27 @@ qemudCanonicalizeMachine(struct qemud_driver *driver, virDomainDefPtr def)
|
||||
|
||||
for (i = 0; i < driver->caps->nguests; i++) {
|
||||
virCapsGuestPtr guest = driver->caps->guests[i];
|
||||
virCapsGuestDomainInfoPtr info;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < guest->arch.ndomains; j++) {
|
||||
virCapsGuestDomainPtr dom = guest->arch.domains[j];
|
||||
info = &guest->arch.domains[j]->info;
|
||||
|
||||
if (dom->info.emulator &&
|
||||
STREQ(dom->info.emulator, def->emulator)) {
|
||||
if (qemudCanonicalizeMachineFromInfo(def, &dom->info,
|
||||
&canonical) < 0)
|
||||
return -1;
|
||||
if (canonical)
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
if (!info->emulator || !STREQ(info->emulator, def->emulator))
|
||||
continue;
|
||||
|
||||
if (!info->nmachines)
|
||||
info = &guest->arch.defaultInfo;
|
||||
|
||||
if (qemudCanonicalizeMachineFromInfo(def, info, &canonical) < 0)
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* if we matched one of the domain's emulators, or if
|
||||
* we match the default emulator
|
||||
*/
|
||||
if (j < guest->arch.ndomains ||
|
||||
(guest->arch.defaultInfo.emulator &&
|
||||
STREQ(guest->arch.defaultInfo.emulator, def->emulator))) {
|
||||
if (qemudCanonicalizeMachineFromInfo(def, &guest->arch.defaultInfo,
|
||||
&canonical) < 0)
|
||||
info = &guest->arch.defaultInfo;
|
||||
|
||||
if (info->emulator && STREQ(info->emulator, def->emulator)) {
|
||||
if (qemudCanonicalizeMachineFromInfo(def, info, &canonical) < 0)
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user