2008-07-25 13:17:27 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "testutilsxen.h"
|
|
|
|
|
|
|
|
virCapsPtr testXenCapsInit(void) {
|
|
|
|
struct utsname utsname;
|
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
2009-07-27 15:45:01 +00:00
|
|
|
virCapsGuestMachinePtr *machines;
|
|
|
|
int nmachines;
|
2008-07-25 13:17:27 +00:00
|
|
|
static const char *const x86_machines[] = {
|
|
|
|
"xenfv"
|
|
|
|
};
|
|
|
|
static const char *const xen_machines[] = {
|
|
|
|
"xenpv"
|
|
|
|
};
|
|
|
|
|
|
|
|
uname (&utsname);
|
|
|
|
if ((caps = virCapabilitiesNew(utsname.machine,
|
|
|
|
0, 0)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2009-07-27 15:45:01 +00:00
|
|
|
nmachines = ARRAY_CARDINALITY(x86_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-07-25 13:17:27 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
|
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
2009-07-27 15:45:01 +00:00
|
|
|
nmachines, machines)) == NULL)
|
2008-07-25 13:17:27 +00:00
|
|
|
goto cleanup;
|
2009-07-27 15:45:01 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-07-25 13:17:27 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"xen",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-07-27 15:45:01 +00:00
|
|
|
nmachines = ARRAY_CARDINALITY(xen_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-07-25 13:17:27 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "xen", "i686", 32,
|
|
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
2009-07-27 15:45:01 +00:00
|
|
|
nmachines, machines)) == NULL)
|
2008-07-25 13:17:27 +00:00
|
|
|
goto cleanup;
|
2009-07-27 15:45:01 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-07-25 13:17:27 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"xen",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
cleanup:
|
2009-07-27 15:45:01 +00:00
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
2008-07-25 13:17:27 +00:00
|
|
|
virCapabilitiesFree(caps);
|
|
|
|
return NULL;
|
|
|
|
}
|