1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

qemu: Refactor default panic model

Perform decisions based on the architecture and machine type
in a single place instead of duplicating them.

This technically adds new behavior for MODEL_ISA in
qemuDomainDefAddDefaultDevices(), but it doesn't make any
difference functionally since we don't set addPanicDevice
outside of ppc64(le) and s390(x). If we did, the lack of
handling for that value would be a latent bug.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrea Bolognani 2024-08-27 15:03:31 +02:00
parent f22583c6c4
commit 9e1970efa5

View File

@ -4150,6 +4150,19 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def,
}
static virDomainPanicModel
qemuDomainDefaultPanicModel(const virDomainDef *def)
{
if (qemuDomainIsPSeries(def))
return VIR_DOMAIN_PANIC_MODEL_PSERIES;
if (ARCH_IS_S390(def->os.arch))
return VIR_DOMAIN_PANIC_MODEL_S390;
return VIR_DOMAIN_PANIC_MODEL_ISA;
}
static int
qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
virDomainDef *def,
@ -4397,13 +4410,12 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
return -1;
if (addPanicDevice) {
virDomainPanicModel defaultModel = qemuDomainDefaultPanicModel(def);
size_t j;
for (j = 0; j < def->npanics; j++) {
if (def->panics[j]->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT ||
(ARCH_IS_PPC64(def->os.arch) &&
def->panics[j]->model == VIR_DOMAIN_PANIC_MODEL_PSERIES) ||
(ARCH_IS_S390(def->os.arch) &&
def->panics[j]->model == VIR_DOMAIN_PANIC_MODEL_S390))
def->panics[j]->model == defaultModel)
break;
}
@ -6100,14 +6112,8 @@ static int
qemuDomainDevicePanicDefPostParse(virDomainPanicDef *panic,
const virDomainDef *def)
{
if (panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT) {
if (qemuDomainIsPSeries(def))
panic->model = VIR_DOMAIN_PANIC_MODEL_PSERIES;
else if (ARCH_IS_S390(def->os.arch))
panic->model = VIR_DOMAIN_PANIC_MODEL_S390;
else
panic->model = VIR_DOMAIN_PANIC_MODEL_ISA;
}
if (panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT)
panic->model = qemuDomainDefaultPanicModel(def);
return 0;
}