mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
b1c88c1476
For S390, the default console target type cannot be of type 'serial'. It is necessary to at least interpret the 'arch' attribute value of the os/type element to produce the correct default type. Therefore we need to extend the signature of defaultConsoleTargetType to account for architecture. As a consequence all the drivers supporting this capability function must be updated. Despite the amount of changed files, the only change in behavior is that for S390 the default console target type will be 'virtio'. N.B.: A more future-proof approach could be to to use hypervisor specific capabilities to determine the best possible console type. For instance one could add an opaque private data pointer to the virCaps structure (in case of QEMU to hold capsCache) which could then be passed to the defaultConsoleTargetType callback to determine the console target type. Seems to be however a bit overengineered for the use case... Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
81 lines
2.4 KiB
C
81 lines
2.4 KiB
C
#include <config.h>
|
|
|
|
#include <sys/utsname.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "testutilsxen.h"
|
|
#include "domain_conf.h"
|
|
|
|
static int testXenDefaultConsoleType(const char *ostype,
|
|
const char *arch ATTRIBUTE_UNUSED)
|
|
{
|
|
if (STREQ(ostype, "hvm"))
|
|
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
|
else
|
|
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
|
}
|
|
|
|
virCapsPtr testXenCapsInit(void) {
|
|
struct utsname utsname;
|
|
virCapsPtr caps;
|
|
virCapsGuestPtr guest;
|
|
virCapsGuestMachinePtr *machines;
|
|
int nmachines;
|
|
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;
|
|
|
|
caps->defaultConsoleTargetType = testXenDefaultConsoleType;
|
|
|
|
nmachines = ARRAY_CARDINALITY(x86_machines);
|
|
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
|
|
goto cleanup;
|
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
|
nmachines, machines)) == NULL)
|
|
goto cleanup;
|
|
machines = NULL;
|
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
"xen",
|
|
NULL,
|
|
NULL,
|
|
0,
|
|
NULL) == NULL)
|
|
goto cleanup;
|
|
|
|
nmachines = ARRAY_CARDINALITY(xen_machines);
|
|
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
|
|
goto cleanup;
|
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, "xen", "i686", 32,
|
|
"/usr/lib/xen/bin/qemu-dm", NULL,
|
|
nmachines, machines)) == NULL)
|
|
goto cleanup;
|
|
machines = NULL;
|
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
"xen",
|
|
NULL,
|
|
NULL,
|
|
0,
|
|
NULL) == NULL)
|
|
goto cleanup;
|
|
|
|
return caps;
|
|
|
|
cleanup:
|
|
virCapabilitiesFreeMachines(machines, nmachines);
|
|
virCapabilitiesFree(caps);
|
|
return NULL;
|
|
}
|