mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Re-factor qemu test machine allocation code
* test/testutilsqemu.c: split out code to testQemuAllocMachines() and make use of the ARRAY_CARDINALITY macro
This commit is contained in:
parent
6e7ab46106
commit
d4c032d0b7
@ -7,15 +7,29 @@
|
|||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
|
||||||
|
{
|
||||||
|
virCapsGuestMachinePtr *machines;
|
||||||
|
static const char *const x86_machines[] = {
|
||||||
|
"pc", "isapc"
|
||||||
|
};
|
||||||
|
|
||||||
|
machines = virCapabilitiesAllocMachines(x86_machines,
|
||||||
|
ARRAY_CARDINALITY(x86_machines));
|
||||||
|
if (machines == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*nmachines = ARRAY_CARDINALITY(x86_machines);
|
||||||
|
|
||||||
|
return machines;
|
||||||
|
}
|
||||||
|
|
||||||
virCapsPtr testQemuCapsInit(void) {
|
virCapsPtr testQemuCapsInit(void) {
|
||||||
struct utsname utsname;
|
struct utsname utsname;
|
||||||
virCapsPtr caps;
|
virCapsPtr caps;
|
||||||
virCapsGuestPtr guest;
|
virCapsGuestPtr guest;
|
||||||
virCapsGuestMachinePtr *machines;
|
virCapsGuestMachinePtr *machines;
|
||||||
int nmachines;
|
int nmachines;
|
||||||
static const char *const x86_machines[] = {
|
|
||||||
"pc", "isapc"
|
|
||||||
};
|
|
||||||
static const char *const xen_machines[] = {
|
static const char *const xen_machines[] = {
|
||||||
"xenner"
|
"xenner"
|
||||||
};
|
};
|
||||||
@ -25,8 +39,7 @@ virCapsPtr testQemuCapsInit(void) {
|
|||||||
0, 0)) == NULL)
|
0, 0)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
nmachines = 2;
|
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
|
||||||
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
||||||
@ -43,8 +56,7 @@ virCapsPtr testQemuCapsInit(void) {
|
|||||||
NULL) == NULL)
|
NULL) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
nmachines = 2;
|
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
|
||||||
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
|
||||||
@ -68,13 +80,13 @@ virCapsPtr testQemuCapsInit(void) {
|
|||||||
NULL) == NULL)
|
NULL) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
nmachines = 1;
|
nmachines = ARRAY_CARDINALITY(xen_machines);
|
||||||
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps, "xen", "x86_64", 64,
|
if ((guest = virCapabilitiesAddGuest(caps, "xen", "x86_64", 64,
|
||||||
"/usr/bin/xenner", NULL,
|
"/usr/bin/xenner", NULL,
|
||||||
1, machines)) == NULL)
|
nmachines, machines)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
machines = NULL;
|
machines = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user