[libvirt PATCH 11/17] tests: Add HVF support to testutilsqemu
Daniel P. Berrangé
berrange at redhat.com
Wed Jan 5 10:10:07 UTC 2022
On Tue, Jan 04, 2022 at 07:52:50PM +0100, Andrea Bolognani wrote:
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
> tests/testutilsqemu.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
> index 7fdb82daec..a75995c77a 100644
> --- a/tests/testutilsqemu.c
> +++ b/tests/testutilsqemu.c
> @@ -106,6 +106,18 @@ static const char *const *kvm_machines[VIR_ARCH_LAST] = {
> [VIR_ARCH_S390X] = s390x_machines,
> };
>
> +static const char *const *hvf_machines[VIR_ARCH_LAST] = {
> + [VIR_ARCH_I686] = NULL,
> + [VIR_ARCH_X86_64] = x86_64_machines,
> + [VIR_ARCH_AARCH64] = aarch64_machines,
> + [VIR_ARCH_ARMV7L] = NULL,
> + [VIR_ARCH_PPC64] = NULL,
> + [VIR_ARCH_PPC] = NULL,
> + [VIR_ARCH_RISCV32] = NULL,
> + [VIR_ARCH_RISCV64] = NULL,
> + [VIR_ARCH_S390X] = NULL,
> +};
> +
> static const char *qemu_default_ram_id[VIR_ARCH_LAST] = {
> [VIR_ARCH_I686] = "pc.ram",
> [VIR_ARCH_X86_64] = "pc.ram",
> @@ -214,6 +226,18 @@ testQemuAddGuest(virCaps *caps,
> NULL, nmachines, machines);
> }
>
> + if (hvf_machines[emu_arch] != NULL) {
> + nmachines = g_strv_length((char **)hvf_machines[emu_arch]);
> + machines = virCapabilitiesAllocMachines(hvf_machines[emu_arch],
> + nmachines);
> + if (machines == NULL)
> + goto error;
> +
> + virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_HVF,
> + qemu_emulators[emu_arch],
> + NULL, nmachines, machines);
> + }
> +
> return 0;
>
> error:
> @@ -403,6 +427,22 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
> virQEMUCapsSet(tmpCaps, QEMU_CAPS_KVM);
> }
> }
> + if (hvf_machines[i] != NULL) {
> + for (j = 0; hvf_machines[i][j] != NULL; j++) {
> + virQEMUCapsAddMachine(tmpCaps,
> + VIR_DOMAIN_VIRT_HVF,
> + hvf_machines[i][j],
> + NULL,
> + NULL,
> + 0,
> + false,
> + false,
> + true,
> + defaultRAMid,
> + false);
> + virQEMUCapsSet(tmpCaps, QEMU_CAPS_HVF);
> + }
> + }
> }
IIUC this means in tests we're going to build capabilities that
indicate support for KVM and HVF at the same time. This is not
a scenario that applies in the real world, so I'm a little
uncomfortable with this. It is the simple option, though I
would prefer if the individual tests could express
"gimme capabilities for linux"
vs
"gimme capabilities for macOS"
Also relies on fact that we don't #ifdef any of the interesting
code in the QEMU driver related to KVM/HVF. Probably ok-ish
assumption in most cases, at least for unit tests.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list