2008-07-25 21:17:27 +08:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "testutilsxen.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 21:56:20 +08:00
|
|
|
#include "domain_conf.h"
|
|
|
|
|
|
|
|
static int testXenDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
if (STREQ(ostype, "hvm"))
|
|
|
|
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
|
|
|
else
|
|
|
|
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
|
|
|
}
|
2008-07-25 21:17:27 +08:00
|
|
|
|
|
|
|
virCapsPtr testXenCapsInit(void) {
|
|
|
|
struct utsname utsname;
|
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
2009-07-27 23:45:01 +08:00
|
|
|
virCapsGuestMachinePtr *machines;
|
|
|
|
int nmachines;
|
2008-07-25 21:17:27 +08: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;
|
|
|
|
|
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 21:56:20 +08:00
|
|
|
caps->defaultConsoleTargetType = testXenDefaultConsoleType;
|
|
|
|
|
2009-07-27 23:45:01 +08:00
|
|
|
nmachines = ARRAY_CARDINALITY(x86_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-07-25 21:17:27 +08:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
|
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
2009-07-27 23:45:01 +08:00
|
|
|
nmachines, machines)) == NULL)
|
2008-07-25 21:17:27 +08:00
|
|
|
goto cleanup;
|
2009-07-27 23:45:01 +08:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-07-25 21:17:27 +08:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"xen",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-07-27 23:45:01 +08:00
|
|
|
nmachines = ARRAY_CARDINALITY(xen_machines);
|
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-07-25 21:17:27 +08:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "xen", "i686", 32,
|
|
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
2009-07-27 23:45:01 +08:00
|
|
|
nmachines, machines)) == NULL)
|
2008-07-25 21:17:27 +08:00
|
|
|
goto cleanup;
|
2009-07-27 23:45:01 +08:00
|
|
|
machines = NULL;
|
|
|
|
|
2008-07-25 21:17:27 +08:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"xen",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
|
|
|
cleanup:
|
2009-07-27 23:45:01 +08:00
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
2008-07-25 21:17:27 +08:00
|
|
|
virCapabilitiesFree(caps);
|
|
|
|
return NULL;
|
|
|
|
}
|