[PATCH v2 01/29] qemu_domain.c: add PowerNV machine helpers

Daniel Henrique Barboza danielhb413 at gmail.com
Tue Jan 25 20:48:34 UTC 2022


The PowerNV (Power Non-Virtualized) QEMU ppc64 machine is the emulation
of a bare-metal IBM Power host.  It follows the OPAL (OpenPower
Abstration Layer) API/ABI, most specifically Skiboot [1]. For now,
Libvirt has support for the pSeries QEMU machine, which is the emulation
of a logical partition (guest) that would run on top of a bare-metal
system.

This patch introduces the helpers that are going to be used to add a
basic support for PowerNV domains in Libvirt. Given that there are quite
a few similarities in how pSeries and PowerNVv should be handled, we're
also adding a 'qemuDomainIsPowerPC' helper that will be used in those
instances.

[1] https://open-power.github.io/skiboot/doc/overview.html

Reviewed-by: Peter Krempa <pkrempa at redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_domain.h |  4 ++++
 2 files changed, 45 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index aa8f6b8d05..2e21a95f38 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8719,6 +8719,47 @@ qemuDomainIsPSeries(const virDomainDef *def)
 }
 
 
+/*
+ * The PowerNV machine does not support KVM acceleration in Power
+ * hosts. We can skip the usual ARCH_IS_PPC64() since this machine
+ * is usable with TCG in all host archs.
+ */
+bool
+qemuDomainIsPowerNV(const virDomainDef *def)
+{
+    if (STRPREFIX(def->os.machine, "powernv"))
+        return true;
+
+    return false;
+}
+
+
+/*
+ * PowerNV and pSeries domains shares a lot of common traits. This
+ * helper avoids repeating "if (pseries || powernv)" everywhere this
+ * is applicable.
+ */
+bool
+qemuDomainIsPowerPC(const virDomainDef *def)
+{
+    return qemuDomainIsPSeries(def) || qemuDomainIsPowerNV(def);
+}
+
+
+/*
+ * Similar to qemuDomainIsPowerPC(). Usable when the caller doesn't
+ * have access to a virDomainDef pointer.
+ */
+bool
+qemuDomainMachineIsPowerPC(const char *machine, const virArch arch)
+{
+    if (STRPREFIX(machine, "powernv"))
+        return true;
+
+    return qemuDomainMachineIsPSeries(machine, arch);
+}
+
+
 bool
 qemuDomainHasPCIRoot(const virDomainDef *def)
 {
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index e5046367e3..d07a279a1b 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -761,6 +761,8 @@ bool qemuDomainMachineIsARMVirt(const char *machine,
                                 const virArch arch);
 bool qemuDomainMachineIsPSeries(const char *machine,
                                 const virArch arch);
+bool qemuDomainMachineIsPowerPC(const char *machine,
+                                const virArch arch);
 bool qemuDomainMachineHasBuiltinIDE(const char *machine,
                                     const virArch arch);
 
@@ -770,6 +772,8 @@ bool qemuDomainIsS390CCW(const virDomainDef *def);
 bool qemuDomainIsARMVirt(const virDomainDef *def);
 bool qemuDomainIsRISCVVirt(const virDomainDef *def);
 bool qemuDomainIsPSeries(const virDomainDef *def);
+bool qemuDomainIsPowerNV(const virDomainDef *def);
+bool qemuDomainIsPowerPC(const virDomainDef *def);
 bool qemuDomainHasPCIRoot(const virDomainDef *def);
 bool qemuDomainHasPCIeRoot(const virDomainDef *def);
 bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
-- 
2.34.1




More information about the libvir-list mailing list