]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Improve qemuDomainSupportsPCI()
authorAndrea Bolognani <abologna@redhat.com>
Tue, 16 Jan 2024 15:42:18 +0000 (16:42 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 17 Jan 2024 18:28:29 +0000 (19:28 +0100)
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>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h

index 7c87cd6453e25e216eeee6752dbd3ac05afc60e7..80281d9b482365b5dd392cf0d9824212bb18b201 100644 (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;
 }
 
 
index b0f1587f58710d48944e6009573f5243ad2c38a3..49e0fcf4989f5dc989a428110f775152dbdd6b59 100644 (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);