2008-07-25 13:17:27 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
|
|
|
|
|
#include "testutilsxen.h"
|
2017-07-21 14:24:51 +02:00
|
|
|
#include "testutilshostcpus.h"
|
2011-10-20 14:56:20 +01:00
|
|
|
#include "domain_conf.h"
|
|
|
|
|
|
2014-12-15 21:30:05 -07:00
|
|
|
virCapsPtr
|
|
|
|
|
testXLInitCaps(void)
|
|
|
|
|
{
|
|
|
|
|
virCapsPtr caps;
|
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
|
virCapsGuestMachinePtr *machines;
|
|
|
|
|
int nmachines;
|
|
|
|
|
static const char *const x86_machines[] = {
|
|
|
|
|
"xenfv"
|
|
|
|
|
};
|
|
|
|
|
static const char *const xen_machines[] = {
|
2018-11-26 20:34:40 +01:00
|
|
|
"xenpv",
|
|
|
|
|
};
|
|
|
|
|
static const char *const pvh_machines[] = {
|
|
|
|
|
"xenpvh",
|
2014-12-15 21:30:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if ((caps = virCapabilitiesNew(virArchFromHost(),
|
|
|
|
|
false, false)) == NULL)
|
|
|
|
|
return NULL;
|
2017-04-24 15:07:01 +02:00
|
|
|
|
|
|
|
|
caps->host.cpu = virCPUDefCopy(&cpuDefaultData);
|
|
|
|
|
|
2019-10-15 13:55:26 +02:00
|
|
|
nmachines = G_N_ELEMENTS(x86_machines);
|
2014-12-15 21:30:05 -07:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
|
goto cleanup;
|
2015-04-17 18:09:16 -04:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
|
|
|
|
VIR_ARCH_X86_64,
|
2015-03-19 19:03:08 -06:00
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
|
"/usr/lib/xen/boot/hvmloader",
|
2014-12-15 21:30:05 -07:00
|
|
|
nmachines, machines)) == NULL)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
machines = NULL;
|
2015-04-17 18:38:10 -04:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
2014-12-15 21:30:05 -07:00
|
|
|
NULL, 0, NULL) == NULL)
|
|
|
|
|
goto cleanup;
|
2019-10-15 13:55:26 +02:00
|
|
|
nmachines = G_N_ELEMENTS(xen_machines);
|
2014-12-15 21:30:05 -07:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2015-04-17 18:09:16 -04:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN,
|
|
|
|
|
VIR_ARCH_X86_64,
|
2015-03-19 19:03:08 -06:00
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
|
NULL,
|
|
|
|
|
nmachines, machines)) == NULL)
|
2014-12-15 21:30:05 -07:00
|
|
|
goto cleanup;
|
|
|
|
|
machines = NULL;
|
|
|
|
|
|
2018-11-26 20:34:40 +01:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
|
|
|
|
NULL, 0, NULL) == NULL)
|
|
|
|
|
goto cleanup;
|
2019-10-15 13:55:26 +02:00
|
|
|
nmachines = G_N_ELEMENTS(pvh_machines);
|
2018-11-26 20:34:40 +01:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(pvh_machines, nmachines)) == NULL)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XENPVH,
|
|
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
|
NULL,
|
|
|
|
|
nmachines, machines)) == NULL)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
machines = NULL;
|
|
|
|
|
|
2015-04-17 18:38:10 -04:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
2014-12-15 21:30:05 -07:00
|
|
|
NULL, 0, NULL) == NULL)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
|
|
|
virObjectUnref(caps);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|