mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
tests: Introduce testQemuHostOS
This new enumeration provides a way to specify the host OS that a specific test case expects. The default is Linux, which has been the implicit host OS until now; when Linux is selected as the host OS, KVM support is advertised in capabilies data exposed to test cases. This commit doesn't result in any functional change, and simply sets the stage for introducing macOS host OS support later. 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
244542f3bf
commit
f16626ccd7
@ -160,7 +160,8 @@ virHostCPUX86GetCPUID(uint32_t leaf,
|
||||
|
||||
static int
|
||||
testQemuAddGuest(virCaps *caps,
|
||||
virArch arch)
|
||||
virArch arch,
|
||||
testQemuHostOS hostOS)
|
||||
{
|
||||
size_t nmachines;
|
||||
virCapsGuestMachine **machines = NULL;
|
||||
@ -193,6 +194,7 @@ testQemuAddGuest(virCaps *caps,
|
||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||
NULL, NULL, 0, NULL);
|
||||
|
||||
if (hostOS == HOST_OS_LINUX) {
|
||||
if (kvm_machines[emu_arch] != NULL) {
|
||||
nmachines = g_strv_length((char **)kvm_machines[emu_arch]);
|
||||
machines = virCapabilitiesAllocMachines(kvm_machines[emu_arch],
|
||||
@ -204,6 +206,7 @@ testQemuAddGuest(virCaps *caps,
|
||||
qemu_emulators[emu_arch],
|
||||
NULL, nmachines, machines);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -213,7 +216,8 @@ testQemuAddGuest(virCaps *caps,
|
||||
}
|
||||
|
||||
|
||||
virCaps *testQemuCapsInit(void)
|
||||
static virCaps*
|
||||
testQemuCapsInitImpl(testQemuHostOS hostOS)
|
||||
{
|
||||
virCaps *caps;
|
||||
size_t i;
|
||||
@ -233,7 +237,7 @@ virCaps *testQemuCapsInit(void)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < VIR_ARCH_LAST; i++) {
|
||||
if (testQemuAddGuest(caps, i) < 0)
|
||||
if (testQemuAddGuest(caps, i, hostOS) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -255,6 +259,12 @@ virCaps *testQemuCapsInit(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virCaps*
|
||||
testQemuCapsInit(void)
|
||||
{
|
||||
return testQemuCapsInitImpl(HOST_OS_LINUX);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qemuTestSetHostArch(virQEMUDriver *driver,
|
||||
@ -338,7 +348,8 @@ void qemuTestDriverFree(virQEMUDriver *driver)
|
||||
|
||||
static void
|
||||
qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
||||
virArch arch)
|
||||
virArch arch,
|
||||
testQemuHostOS hostOS)
|
||||
{
|
||||
size_t i;
|
||||
const char *defaultRAMid = NULL;
|
||||
@ -366,6 +377,7 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
||||
virQEMUCapsSet(caps, QEMU_CAPS_TCG);
|
||||
}
|
||||
|
||||
if (hostOS == HOST_OS_LINUX) {
|
||||
if (kvm_machines[arch] != NULL) {
|
||||
for (i = 0; kvm_machines[arch][i] != NULL; i++) {
|
||||
virQEMUCapsAddMachine(caps,
|
||||
@ -383,6 +395,7 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
@ -399,8 +412,10 @@ qemuTestCapsCacheInsertData(virFileCache *cache,
|
||||
}
|
||||
|
||||
|
||||
int qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
virQEMUCaps *caps)
|
||||
static int
|
||||
qemuTestCapsCacheInsertImpl(virFileCache *cache,
|
||||
virQEMUCaps *caps,
|
||||
testQemuHostOS hostOS)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@ -425,7 +440,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
if (!(copyCaps = effCaps = virQEMUCapsNewCopy(caps)))
|
||||
return -1;
|
||||
|
||||
qemuTestCapsPopulateFakeMachines(copyCaps, arch);
|
||||
qemuTestCapsPopulateFakeMachines(copyCaps, arch, hostOS);
|
||||
}
|
||||
|
||||
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0)
|
||||
@ -460,7 +475,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
if (!tmp)
|
||||
return -1;
|
||||
|
||||
qemuTestCapsPopulateFakeMachines(tmp, i);
|
||||
qemuTestCapsPopulateFakeMachines(tmp, i, hostOS);
|
||||
|
||||
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], tmp) < 0)
|
||||
return -1;
|
||||
@ -470,6 +485,13 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
qemuTestCapsCacheInsert(virFileCache *cache,
|
||||
virQEMUCaps *caps)
|
||||
{
|
||||
return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_LINUX);
|
||||
}
|
||||
|
||||
|
||||
# define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX"
|
||||
# define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX"
|
||||
|
@ -33,6 +33,10 @@ enum {
|
||||
GIC_BOTH,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
HOST_OS_LINUX = 0,
|
||||
} testQemuHostOS;
|
||||
|
||||
typedef enum {
|
||||
ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1,
|
||||
ARG_GIC,
|
||||
|
Loading…
x
Reference in New Issue
Block a user