mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
tests: Add macOS support to testutilsqemu
This exposes a couple of macOS-specific variants of existing APIs, which can be used when implementing test programs and result in HVF support being advertised. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Tested-by: Brad Laue <brad@brad-x.com> Tested-by: Christophe Fergeau <cfergeau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
f16626ccd7
commit
5fd9ddfa1f
@ -97,6 +97,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",
|
||||
@ -208,6 +220,20 @@ testQemuAddGuest(virCaps *caps,
|
||||
}
|
||||
}
|
||||
|
||||
if (hostOS == HOST_OS_MACOS) {
|
||||
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:
|
||||
@ -265,6 +291,12 @@ testQemuCapsInit(void)
|
||||
return testQemuCapsInitImpl(HOST_OS_LINUX);
|
||||
}
|
||||
|
||||
virCaps*
|
||||
testQemuCapsInitMacOS(void)
|
||||
{
|
||||
return testQemuCapsInitImpl(HOST_OS_MACOS);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qemuTestSetHostArch(virQEMUDriver *driver,
|
||||
@ -395,6 +427,25 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hostOS == HOST_OS_MACOS) {
|
||||
if (hvf_machines[arch] != NULL) {
|
||||
for (i = 0; hvf_machines[arch][i] != NULL; i++) {
|
||||
virQEMUCapsAddMachine(caps,
|
||||
VIR_DOMAIN_VIRT_HVF,
|
||||
hvf_machines[arch][i],
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
defaultRAMid,
|
||||
false);
|
||||
virQEMUCapsSet(caps, QEMU_CAPS_HVF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -492,6 +543,13 @@ qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_LINUX);
|
||||
}
|
||||
|
||||
int
|
||||
qemuTestCapsCacheInsertMacOS(virFileCache *cache,
|
||||
virQEMUCaps *caps)
|
||||
{
|
||||
return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_MACOS);
|
||||
}
|
||||
|
||||
|
||||
# define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX"
|
||||
# define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX"
|
||||
|
@ -35,6 +35,7 @@ enum {
|
||||
|
||||
typedef enum {
|
||||
HOST_OS_LINUX = 0,
|
||||
HOST_OS_MACOS,
|
||||
} testQemuHostOS;
|
||||
|
||||
typedef enum {
|
||||
@ -92,6 +93,7 @@ struct testQemuInfo {
|
||||
};
|
||||
|
||||
virCaps *testQemuCapsInit(void);
|
||||
virCaps *testQemuCapsInitMacOS(void);
|
||||
virDomainXMLOption *testQemuXMLConfInit(void);
|
||||
|
||||
|
||||
@ -113,6 +115,8 @@ int qemuTestDriverInit(virQEMUDriver *driver);
|
||||
void qemuTestDriverFree(virQEMUDriver *driver);
|
||||
int qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
virQEMUCaps *caps);
|
||||
int qemuTestCapsCacheInsertMacOS(virFileCache *cache,
|
||||
virQEMUCaps *caps);
|
||||
|
||||
int testQemuCapsSetGIC(virQEMUCaps *qemuCaps,
|
||||
int gic);
|
||||
|
Loading…
Reference in New Issue
Block a user