2008-05-22 16:18:40 +00:00
|
|
|
#include <config.h>
|
2008-06-26 09:37:51 +00:00
|
|
|
#ifdef WITH_QEMU
|
2008-05-16 16:51:30 +00:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "testutilsqemu.h"
|
|
|
|
|
|
|
|
virCapsPtr testQemuCapsInit(void) {
|
|
|
|
struct utsname utsname;
|
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
2009-07-23 17:31:34 +00:00
|
|
|
virCapsGuestMachinePtr *machines;
|
|
|
|
int nmachines;
|
2008-05-16 16:51:30 +00:00
|
|
|
static const char *const x86_machines[] = {
|
|
|
|
"pc", "isapc"
|
|
|
|
};
|
|
|
|
static const char *const xen_machines[] = {
|
|
|
|
"xenner"
|
|
|
|
};
|
|
|
|
|
|
|
|
uname (&utsname);
|
|
|
|
if ((caps = virCapabilitiesNew(utsname.machine,
|
|
|
|
0, 0)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2009-07-23 17:31:34 +00:00
|
|
|
nmachines = 2;
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
|
|
|
"/usr/bin/qemu", NULL,
|
2009-07-23 17:31:34 +00:00
|
|
|
nmachines, machines)) == NULL)
|
2008-05-16 16:51:30 +00:00
|
|
|
goto cleanup;
|
2009-07-23 17:31:34 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"qemu",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-07-23 17:31:34 +00:00
|
|
|
nmachines = 2;
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
|
|
|
|
"/usr/bin/qemu-system-x86_64", NULL,
|
2009-07-23 17:31:34 +00:00
|
|
|
nmachines, machines)) == NULL)
|
2008-05-16 16:51:30 +00:00
|
|
|
goto cleanup;
|
2009-07-23 17:31:34 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"qemu",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"kvm",
|
|
|
|
"/usr/bin/kvm",
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-07-23 17:31:34 +00:00
|
|
|
nmachines = 1;
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "xen", "x86_64", 64,
|
|
|
|
"/usr/bin/xenner", NULL,
|
2009-07-23 17:31:34 +00:00
|
|
|
1, machines)) == NULL)
|
2008-05-16 16:51:30 +00:00
|
|
|
goto cleanup;
|
2009-07-23 17:31:34 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-05-16 16:51:30 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"kvm",
|
|
|
|
"/usr/bin/kvm",
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
cleanup:
|
2009-07-23 17:31:34 +00:00
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
2008-05-16 16:51:30 +00:00
|
|
|
virCapabilitiesFree(caps);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-06-26 09:37:51 +00:00
|
|
|
#endif
|