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

Daniel Henrique Barboza posted 29 patches 4 years ago
There is a newer version of this series
[PATCH v2 01/29] qemu_domain.c: add PowerNV machine helpers
Posted by Daniel Henrique Barboza 4 years ago
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@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@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

Re: [PATCH v2 01/29] qemu_domain.c: add PowerNV machine helpers
Posted by Ján Tomko 3 years, 11 months ago
On a Tuesday in 2022, Daniel Henrique Barboza wrote:
>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

s/Libvirt/libvirt/

>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

s/Libvirt/libvirt/

>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@redhat.com>
>Signed-off-by: Daniel Henrique Barboza <danielhb413@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.

I don't understand the comment. We use these ARCH_ macros
to check the guest arch, not the host arch. So the check
should be here too.

>+ */
>+bool
>+qemuDomainIsPowerNV(const virDomainDef *def)
>+{
>+    if (STRPREFIX(def->os.machine, "powernv"))
>+        return true;
>+
>+    return false;
>+}
>+
>+

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
Re: [PATCH v2 01/29] qemu_domain.c: add PowerNV machine helpers
Posted by Daniel Henrique Barboza 3 years, 11 months ago

On 2/21/22 09:47, Ján Tomko wrote:
> On a Tuesday in 2022, Daniel Henrique Barboza wrote:
>> 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
> 
> s/Libvirt/libvirt/

I think I've been using capital L for a long time now. I'll make sure to pay
attention next time.


> 
>> 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
> 
> s/Libvirt/libvirt/
> 
>> 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@redhat.com>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@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.
> 
> I don't understand the comment. We use these ARCH_ macros
> to check the guest arch, not the host arch. So the check
> should be here too.


True. I removed the comment.


Thanks,


Daniel

> 
>> + */
>> +bool
>> +qemuDomainIsPowerNV(const virDomainDef *def)
>> +{
>> +    if (STRPREFIX(def->os.machine, "powernv"))
>> +        return true;
>> +
>> +    return false;
>> +}
>> +
>> +
> 
> Reviewed-by: Ján Tomko <jtomko@redhat.com>
> 
> Jano