2008-07-25 13:17:27 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "testutilsxen.h"
|
2017-07-21 12:24:51 +00:00
|
|
|
#include "testutilshostcpus.h"
|
Fix default console type setting
The default console type may vary based on the OS type. ie a Xen
paravirt guests wants a 'xen' console, while a fullvirt guests
wants a 'serial' console.
A plain integer default console type in the capabilities does
not suffice. Instead introduce a callback that is passed the
OS type.
* src/conf/capabilities.h: Use a callback for default console
type
* src/conf/domain_conf.c, src/conf/domain_conf.h: Use callback
for default console type. Add missing LXC/OpenVZ console types.
* src/esx/esx_driver.c, src/libxl/libxl_conf.c,
src/lxc/lxc_conf.c, src/openvz/openvz_conf.c,
src/phyp/phyp_driver.c, src/qemu/qemu_capabilities.c,
src/uml/uml_conf.c, src/vbox/vbox_tmpl.c,
src/vmware/vmware_conf.c, src/xen/xen_hypervisor.c,
src/xenapi/xenapi_driver.c: Set default console type callback
2011-10-20 13:56:20 +00:00
|
|
|
#include "domain_conf.h"
|
|
|
|
|
2014-03-18 08:13:43 +00:00
|
|
|
virCapsPtr testXenCapsInit(void)
|
|
|
|
{
|
2008-07-25 13:17:27 +00:00
|
|
|
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"
|
|
|
|
};
|
|
|
|
|
2012-10-17 09:23:12 +00:00
|
|
|
uname(&utsname);
|
2012-12-18 19:32:23 +00:00
|
|
|
if ((caps = virCapabilitiesNew(VIR_ARCH_I686,
|
2014-07-14 12:56:13 +00:00
|
|
|
false, false)) == NULL)
|
2008-07-25 13:17:27 +00:00
|
|
|
return NULL;
|
|
|
|
|
2009-07-27 15:45:01 +00:00
|
|
|
nmachines = ARRAY_CARDINALITY(x86_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
|
2008-07-25 13:17:27 +00:00
|
|
|
"/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,
|
2015-04-17 22:38:10 +00:00
|
|
|
VIR_DOMAIN_VIRT_XEN,
|
2008-07-25 13:17:27 +00:00
|
|
|
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;
|
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_I686,
|
2008-07-25 13:17:27 +00:00
|
|
|
"/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,
|
2015-04-17 22:38:10 +00:00
|
|
|
VIR_DOMAIN_VIRT_XEN,
|
2008-07-25 13:17:27 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
2014-03-25 06:53:44 +00:00
|
|
|
cleanup:
|
2009-07-27 15:45:01 +00:00
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(caps);
|
2008-07-25 13:17:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-12-16 04:30:05 +00: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[] = {
|
|
|
|
"xenpv"
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((caps = virCapabilitiesNew(virArchFromHost(),
|
|
|
|
false, false)) == NULL)
|
|
|
|
return NULL;
|
2017-04-24 13:07:01 +00:00
|
|
|
|
|
|
|
caps->host.cpu = virCPUDefCopy(&cpuDefaultData);
|
|
|
|
|
2014-12-16 04:30:05 +00:00
|
|
|
nmachines = ARRAY_CARDINALITY(x86_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
|
|
|
VIR_ARCH_X86_64,
|
2015-03-20 01:03:08 +00:00
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
"/usr/lib/xen/boot/hvmloader",
|
2014-12-16 04:30:05 +00:00
|
|
|
nmachines, machines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
machines = NULL;
|
2015-04-17 22:38:10 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
2014-12-16 04:30:05 +00:00
|
|
|
NULL, 0, NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
nmachines = ARRAY_CARDINALITY(xen_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN,
|
|
|
|
VIR_ARCH_X86_64,
|
2015-03-20 01:03:08 +00:00
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
NULL,
|
|
|
|
nmachines, machines)) == NULL)
|
2014-12-16 04:30:05 +00:00
|
|
|
goto cleanup;
|
|
|
|
machines = NULL;
|
|
|
|
|
2015-04-17 22:38:10 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
|
2014-12-16 04:30:05 +00:00
|
|
|
NULL, 0, NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
|
|
virObjectUnref(caps);
|
|
|
|
return NULL;
|
|
|
|
}
|