mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +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
|
static int
|
||||||
testQemuAddGuest(virCaps *caps,
|
testQemuAddGuest(virCaps *caps,
|
||||||
virArch arch)
|
virArch arch,
|
||||||
|
testQemuHostOS hostOS)
|
||||||
{
|
{
|
||||||
size_t nmachines;
|
size_t nmachines;
|
||||||
virCapsGuestMachine **machines = NULL;
|
virCapsGuestMachine **machines = NULL;
|
||||||
@ -193,6 +194,7 @@ testQemuAddGuest(virCaps *caps,
|
|||||||
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU,
|
||||||
NULL, NULL, 0, NULL);
|
NULL, NULL, 0, NULL);
|
||||||
|
|
||||||
|
if (hostOS == HOST_OS_LINUX) {
|
||||||
if (kvm_machines[emu_arch] != NULL) {
|
if (kvm_machines[emu_arch] != NULL) {
|
||||||
nmachines = g_strv_length((char **)kvm_machines[emu_arch]);
|
nmachines = g_strv_length((char **)kvm_machines[emu_arch]);
|
||||||
machines = virCapabilitiesAllocMachines(kvm_machines[emu_arch],
|
machines = virCapabilitiesAllocMachines(kvm_machines[emu_arch],
|
||||||
@ -204,6 +206,7 @@ testQemuAddGuest(virCaps *caps,
|
|||||||
qemu_emulators[emu_arch],
|
qemu_emulators[emu_arch],
|
||||||
NULL, nmachines, machines);
|
NULL, nmachines, machines);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -213,7 +216,8 @@ testQemuAddGuest(virCaps *caps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virCaps *testQemuCapsInit(void)
|
static virCaps*
|
||||||
|
testQemuCapsInitImpl(testQemuHostOS hostOS)
|
||||||
{
|
{
|
||||||
virCaps *caps;
|
virCaps *caps;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -233,7 +237,7 @@ virCaps *testQemuCapsInit(void)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < VIR_ARCH_LAST; i++) {
|
for (i = 0; i < VIR_ARCH_LAST; i++) {
|
||||||
if (testQemuAddGuest(caps, i) < 0)
|
if (testQemuAddGuest(caps, i, hostOS) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,6 +259,12 @@ virCaps *testQemuCapsInit(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virCaps*
|
||||||
|
testQemuCapsInit(void)
|
||||||
|
{
|
||||||
|
return testQemuCapsInitImpl(HOST_OS_LINUX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
qemuTestSetHostArch(virQEMUDriver *driver,
|
qemuTestSetHostArch(virQEMUDriver *driver,
|
||||||
@ -338,7 +348,8 @@ void qemuTestDriverFree(virQEMUDriver *driver)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
||||||
virArch arch)
|
virArch arch,
|
||||||
|
testQemuHostOS hostOS)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const char *defaultRAMid = NULL;
|
const char *defaultRAMid = NULL;
|
||||||
@ -366,6 +377,7 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
|||||||
virQEMUCapsSet(caps, QEMU_CAPS_TCG);
|
virQEMUCapsSet(caps, QEMU_CAPS_TCG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hostOS == HOST_OS_LINUX) {
|
||||||
if (kvm_machines[arch] != NULL) {
|
if (kvm_machines[arch] != NULL) {
|
||||||
for (i = 0; kvm_machines[arch][i] != NULL; i++) {
|
for (i = 0; kvm_machines[arch][i] != NULL; i++) {
|
||||||
virQEMUCapsAddMachine(caps,
|
virQEMUCapsAddMachine(caps,
|
||||||
@ -382,6 +394,7 @@ qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps,
|
|||||||
virQEMUCapsSet(caps, QEMU_CAPS_KVM);
|
virQEMUCapsSet(caps, QEMU_CAPS_KVM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -399,8 +412,10 @@ qemuTestCapsCacheInsertData(virFileCache *cache,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuTestCapsCacheInsert(virFileCache *cache,
|
static int
|
||||||
virQEMUCaps *caps)
|
qemuTestCapsCacheInsertImpl(virFileCache *cache,
|
||||||
|
virQEMUCaps *caps,
|
||||||
|
testQemuHostOS hostOS)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -425,7 +440,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
|||||||
if (!(copyCaps = effCaps = virQEMUCapsNewCopy(caps)))
|
if (!(copyCaps = effCaps = virQEMUCapsNewCopy(caps)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuTestCapsPopulateFakeMachines(copyCaps, arch);
|
qemuTestCapsPopulateFakeMachines(copyCaps, arch, hostOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0)
|
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0)
|
||||||
@ -460,7 +475,7 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuTestCapsPopulateFakeMachines(tmp, i);
|
qemuTestCapsPopulateFakeMachines(tmp, i, hostOS);
|
||||||
|
|
||||||
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], tmp) < 0)
|
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], tmp) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -470,6 +485,13 @@ int qemuTestCapsCacheInsert(virFileCache *cache,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuTestCapsCacheInsert(virFileCache *cache,
|
||||||
|
virQEMUCaps *caps)
|
||||||
|
{
|
||||||
|
return qemuTestCapsCacheInsertImpl(cache, caps, HOST_OS_LINUX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX"
|
# define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX"
|
||||||
# define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX"
|
# define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX"
|
||||||
|
@ -33,6 +33,10 @@ enum {
|
|||||||
GIC_BOTH,
|
GIC_BOTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
HOST_OS_LINUX = 0,
|
||||||
|
} testQemuHostOS;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1,
|
ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1,
|
||||||
ARG_GIC,
|
ARG_GIC,
|
||||||
|
Loading…
Reference in New Issue
Block a user