2008-07-25 13:17:27 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/utsname.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"
|
|
|
|
|
2019-12-03 10:49:49 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virCaps *
|
2014-12-16 04:30:05 +00:00
|
|
|
testXLInitCaps(void)
|
|
|
|
{
|
2021-12-10 14:07:13 +00:00
|
|
|
g_autoptr(virCaps) caps = NULL;
|
2021-03-11 07:16:13 +00:00
|
|
|
virCapsGuest *guest;
|
|
|
|
virCapsGuestMachine **machines;
|
2014-12-16 04:30:05 +00:00
|
|
|
int nmachines;
|
|
|
|
static const char *const x86_machines[] = {
|
|
|
|
"xenfv"
|
|
|
|
};
|
|
|
|
static const char *const xen_machines[] = {
|
2018-11-26 19:34:40 +00:00
|
|
|
"xenpv",
|
|
|
|
};
|
|
|
|
static const char *const pvh_machines[] = {
|
|
|
|
"xenpvh",
|
2014-12-16 04:30:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if ((caps = virCapabilitiesNew(virArchFromHost(),
|
|
|
|
false, false)) == NULL)
|
|
|
|
return NULL;
|
2017-04-24 13:07:01 +00:00
|
|
|
|
|
|
|
caps->host.cpu = virCPUDefCopy(&cpuDefaultData);
|
|
|
|
|
2019-10-15 11:55:26 +00:00
|
|
|
nmachines = G_N_ELEMENTS(x86_machines);
|
2014-12-16 04:30:05 +00:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
2021-10-07 08:47:27 +00:00
|
|
|
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
"/usr/lib/xen/boot/hvmloader",
|
|
|
|
nmachines, machines);
|
2014-12-16 04:30:05 +00:00
|
|
|
machines = NULL;
|
2021-10-07 08:47:28 +00:00
|
|
|
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
|
|
|
NULL, NULL, 0, NULL);
|
2019-10-15 11:55:26 +00:00
|
|
|
nmachines = G_N_ELEMENTS(xen_machines);
|
2014-12-16 04:30:05 +00:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2021-10-07 08:47:27 +00:00
|
|
|
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN,
|
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
NULL,
|
|
|
|
nmachines, machines);
|
2014-12-16 04:30:05 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2021-10-07 08:47:28 +00:00
|
|
|
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
|
|
|
NULL, NULL, 0, NULL);
|
2019-10-15 11:55:26 +00:00
|
|
|
nmachines = G_N_ELEMENTS(pvh_machines);
|
2018-11-26 19:34:40 +00:00
|
|
|
if ((machines = virCapabilitiesAllocMachines(pvh_machines, nmachines)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2021-10-07 08:47:27 +00:00
|
|
|
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XENPVH,
|
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
"/usr/lib/xen/bin/qemu-system-i386",
|
|
|
|
NULL,
|
|
|
|
nmachines, machines);
|
2018-11-26 19:34:40 +00:00
|
|
|
machines = NULL;
|
|
|
|
|
2021-10-07 08:47:28 +00:00
|
|
|
virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN,
|
|
|
|
NULL, NULL, 0, NULL);
|
2021-12-10 14:07:13 +00:00
|
|
|
return g_steal_pointer(&caps);
|
2014-12-16 04:30:05 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-12-03 10:49:49 +00:00
|
|
|
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
libxlDriverPrivate *testXLInitDriver(void)
|
2019-12-03 10:49:49 +00:00
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
libxlDriverPrivate *driver = g_new0(libxlDriverPrivate, 1);
|
2019-12-03 10:49:49 +00:00
|
|
|
|
|
|
|
if (virMutexInit(&driver->lock) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", "cannot initialize mutex");
|
|
|
|
g_free(driver);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-22 11:44:45 +00:00
|
|
|
if (!(driver->config = libxlDriverConfigNew()))
|
|
|
|
return NULL;
|
2019-12-03 10:49:49 +00:00
|
|
|
|
2020-02-22 12:12:17 +00:00
|
|
|
g_free(driver->config->logDir);
|
|
|
|
driver->config->logDir = g_strdup(abs_builddir);
|
|
|
|
|
2020-02-22 12:01:38 +00:00
|
|
|
if (libxlDriverConfigInit(driver->config) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
2019-12-03 10:49:49 +00:00
|
|
|
driver->config->caps = testXLInitCaps();
|
|
|
|
|
|
|
|
driver->xmlopt = libxlCreateXMLConf(driver);
|
|
|
|
|
|
|
|
return driver;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
void testXLFreeDriver(libxlDriverPrivate *driver)
|
2019-12-03 10:49:49 +00:00
|
|
|
{
|
|
|
|
virObjectUnref(driver->config);
|
|
|
|
virObjectUnref(driver->xmlopt);
|
|
|
|
virMutexDestroy(&driver->lock);
|
|
|
|
g_free(driver);
|
|
|
|
}
|