On Thu, Jan 20, 2022 at 10:52:05 -0300, 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 > 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 > > Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> > --- > 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 a8401bac30..2accd4f766 100644 > --- a/src/qemu/qemu_domain.c > +++ b/src/qemu/qemu_domain.c > @@ -8727,6 +8727,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); > +} Ideally the helpers which take the domain definition will call into the helper which does not so that the machine type check is not duplicated. Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>