libvirt/tests/testutilslxc.c
Viktor Mihajlovski b1c88c1476 capabilities: defaultConsoleTargetType can depend on architecture
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>
2012-11-09 09:20:59 -07:00

65 lines
1.6 KiB
C

#include <config.h>
#ifdef WITH_LXC
# include <stdlib.h>
# include "testutilslxc.h"
# include "testutils.h"
# include "memory.h"
# include "domain_conf.h"
static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
virCapsPtr testLXCCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
if ((caps = virCapabilitiesNew("x86_64",
0, 0)) == NULL)
return NULL;
caps->defaultConsoleTargetType = testLXCDefaultConsoleType;
if ((guest = virCapabilitiesAddGuest(caps, "exe", "i686", 32,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL))
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "exe", "x86_64", 64,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL))
goto error;
if (virTestGetDebug()) {
char *caps_str;
caps_str = virCapabilitiesFormatXML(caps);
if (!caps_str)
goto error;
fprintf(stderr, "LXC driver capabilities:\n%s", caps_str);
VIR_FREE(caps_str);
}
return caps;
error:
virCapabilitiesFree(caps);
return NULL;
}
#endif