[PATCH 2/4] Config some capabilities for loongarch virt machine

Xianglai Li posted 4 patches 11 months, 2 weeks ago
There is a newer version of this series
[PATCH 2/4] Config some capabilities for loongarch virt machine
Posted by Xianglai Li 11 months, 2 weeks ago
From: xianglai li <lixianglai@loongson.cn>

Config some capabilities for loongarch virt machine such as
PCI multi bus.

Signed-off-by: "Xianglai Li" <lixianglai@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
 src/qemu/qemu_capabilities.c | 10 ++++++++--
 src/qemu/qemu_domain.c       | 29 ++++++++++++++++++++++++++++-
 src/qemu/qemu_domain.h       |  1 +
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f2339d6013..357183cdb5 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1138,7 +1138,8 @@ virQEMUCapsInitGuestFromBinary(virCaps *caps,
                                       NULL, NULL, 0, NULL);
     }
 
-    if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64))
+    if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64 ||
+        ARCH_IS_LOONGARCH(guestarch)))
         virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE_TYPE_ACPI,
                                                  true, true);
 
@@ -2080,6 +2081,11 @@ bool virQEMUCapsHasPCIMultiBus(const virDomainDef *def)
         return true;
     }
 
+    /* loongarch64 support PCI-multibus on all machine types
+     * since forever */
+    if (ARCH_IS_LOONGARCH(def->os.arch))
+        return true;
+
     return false;
 }
 
@@ -3742,7 +3748,7 @@ virQEMUCapsInitCPUModel(virQEMUCaps *qemuCaps,
     } else if (ARCH_IS_X86(qemuCaps->arch)) {
         ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, modelInfo,
                                          cpu, migratable);
-    } else if (ARCH_IS_ARM(qemuCaps->arch)) {
+    } else if (ARCH_IS_ARM(qemuCaps->arch) || ARCH_IS_LOONGARCH(qemuCaps->arch)) {
         ret = 2;
     }
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0cea0b323a..e07fc32630 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5635,6 +5635,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
                 else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
+            } else if (ARCH_IS_LOONGARCH(def->os.arch)) {
+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
             }
         }
         /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
@@ -5933,7 +5936,8 @@ qemuDomainDefaultVideoDevice(const virDomainDef *def,
         return VIR_DOMAIN_VIDEO_TYPE_VGA;
     if (qemuDomainIsARMVirt(def) ||
         qemuDomainIsRISCVVirt(def) ||
-        ARCH_IS_S390(def->os.arch)) {
+        ARCH_IS_S390(def->os.arch) ||
+        qemuDomainIsLoongArchVirt(def)) {
         return VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
     }
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA))
@@ -8924,6 +8928,22 @@ qemuDomainMachineIsPSeries(const char *machine,
 }
 
 
+static bool
+qemuDomainMachineIsLoongArchVirt(const char *machine,
+                                 const virArch arch)
+{
+    if (!ARCH_IS_LOONGARCH(arch))
+        return false;
+
+    if (STREQ(machine, "virt") ||
+        STRPREFIX(machine, "virt-")) {
+        return true;
+    }
+
+    return false;
+}
+
+
 static bool
 qemuDomainMachineIsMipsMalta(const char *machine,
                              const virArch arch)
@@ -9017,6 +9037,13 @@ qemuDomainIsMipsMalta(const virDomainDef *def)
 }
 
 
+bool
+qemuDomainIsLoongArchVirt(const virDomainDef *def)
+{
+    return qemuDomainMachineIsLoongArchVirt(def->os.machine, def->os.arch);
+}
+
+
 bool
 qemuDomainHasPCIRoot(const virDomainDef *def)
 {
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index fa566dded6..cbcf3f0996 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -826,6 +826,7 @@ bool qemuDomainIsQ35(const virDomainDef *def);
 bool qemuDomainIsI440FX(const virDomainDef *def);
 bool qemuDomainIsS390CCW(const virDomainDef *def);
 bool qemuDomainIsARMVirt(const virDomainDef *def);
+bool qemuDomainIsLoongArchVirt(const virDomainDef *def);
 bool qemuDomainIsRISCVVirt(const virDomainDef *def);
 bool qemuDomainIsPSeries(const virDomainDef *def);
 bool qemuDomainIsMipsMalta(const virDomainDef *def);
-- 
2.39.1
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org