qemu: Improve qemuDomainSupportsPCI()

The way the function is currently written sort of obscures this
fact, but ultimately we already unconditionally assume PCI
support on most architectures.

Arm and RISC-V need some additional checks to maintain
compatibility with existing configurations but for all future
architectures, such as the upcoming LoongArch64, we expect PCI
support to come out of the box.

Last but not least, the functions is made const-correct.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Andrea Bolognani 2024-01-16 16:42:18 +01:00
parent e622233eda
commit 11a861e9e9
2 changed files with 19 additions and 14 deletions

View File

@ -9059,24 +9059,29 @@ qemuDomainNeedsFDC(const virDomainDef *def)
bool
qemuDomainSupportsPCI(virDomainDef *def)
qemuDomainSupportsPCI(const virDomainDef *def)
{
if (def->os.arch != VIR_ARCH_ARMV6L &&
def->os.arch != VIR_ARCH_ARMV7L &&
def->os.arch != VIR_ARCH_AARCH64 &&
!ARCH_IS_RISCV(def->os.arch)) {
return true;
/* On Arm architectures, only the virt and versatilepb
* machine types support PCI */
if (ARCH_IS_ARM(def->os.arch)) {
if (qemuDomainIsARMVirt(def) ||
STREQ(def->os.machine, "versatilepb")) {
return true;
}
return false;
}
if (STREQ(def->os.machine, "versatilepb"))
return true;
if (qemuDomainIsARMVirt(def) ||
qemuDomainIsRISCVVirt(def)) {
return true;
/* On RISC-V, only the virt machine type supports PCI */
if (ARCH_IS_RISCV(def->os.arch)) {
if (qemuDomainIsRISCVVirt(def)) {
return true;
}
return false;
}
return false;
/* On all other architectures, PCI support is assumed to
* be present */
return true;
}

View File

@ -834,7 +834,7 @@ bool qemuDomainHasPCIeRoot(const virDomainDef *def);
bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
bool qemuDomainHasBuiltinESP(const virDomainDef *def);
bool qemuDomainNeedsFDC(const virDomainDef *def);
bool qemuDomainSupportsPCI(virDomainDef *def);
bool qemuDomainSupportsPCI(const virDomainDef *def);
void qemuDomainUpdateCurrentMemorySize(virDomainObj *vm);