libvirt/tests/testutilslxc.c
Daniel P. Berrange fed92f08db Turn virCapabilities into a virObject
To enable virCapabilities instances to be reference counted,
turn it into a virObject. All cases of virCapabilitiesFree
turn into virObjectUnref

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-02-08 11:34:26 +00:00

65 lines
1.6 KiB
C

#include <config.h>
#ifdef WITH_LXC
# include <stdlib.h>
# include "testutilslxc.h"
# include "testutils.h"
# include "viralloc.h"
# include "domain_conf.h"
static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virArch arch ATTRIBUTE_UNUSED)
{
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
}
virCapsPtr testLXCCapsInit(void) {
virCapsPtr caps;
virCapsGuestPtr guest;
if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64,
0, 0)) == NULL)
return NULL;
caps->defaultConsoleTargetType = testLXCDefaultConsoleType;
if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686,
"/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", VIR_ARCH_X86_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:
virObjectUnref(caps);
return NULL;
}
#endif