libvirt/tests/testutilslxc.c

90 lines
2.1 KiB
C
Raw Normal View History

#include <config.h>
#ifdef WITH_LXC
# include "testutilslxc.h"
# include "testutils.h"
2012-12-12 18:06:53 +00:00
# include "viralloc.h"
# include "domain_conf.h"
# define VIR_FROM_THIS VIR_FROM_LXC
virCapsPtr
testLXCCapsInit(void)
{
virCapsPtr caps;
virCapsGuestPtr guest;
2012-12-18 19:32:23 +00:00
if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64,
capabilities: use bool instead of int While preparing to add a capability for active commit, I noticed that the existing code was abusing int for boolean values. * src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost) (virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve types. * src/conf/capabilities.c (virCapabilitiesNew) (virCapabilitiesAddGuestFeature): Adjust signature. * src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update clients. * src/esx/esx_driver.c (esxCapsInit): Likewise. * src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise. * src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise. * src/openvz/openvz_conf.c (openvzCapsInit): Likewise. * src/parallels/parallels_driver.c (parallelsBuildCapabilities): Likewise. * src/phyp/phyp_driver.c (phypCapsInit): Likewise. * src/qemu/qemu_capabilities.c (virQEMUCapsInit) (virQEMUCapsInitGuestFromBinary): Likewise. * src/security/virt-aa-helper.c (get_definition): Likewise. * src/test/test_driver.c (testBuildCapabilities): Likewise. * src/uml/uml_conf.c (umlCapsInit): Likewise. * src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise. * src/vmware/vmware_conf.c (vmwareCapsInit): Likewise. * src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities): Likewise. * src/xenapi/xenapi_driver.c (getCapsObject): Likewise. * tests/qemucaps2xmltest.c (testGetCaps): Likewise. * tests/testutils.c (virTestGenericCapsInit): Likewise. * tests/testutilslxc.c (testLXCCapsInit): Likewise. * tests/testutilsqemu.c (testQemuCapsInit): Likewise. * tests/testutilsxen.c (testXenCapsInit): Likewise. * tests/vircaps2xmltest.c (buildVirCapabilities): Likewise. * tests/vircapstest.c (buildNUMATopology): Likewise. * tests/vmx2xmltest.c (testCapsInit): Likewise. * tests/xml2vmxtest.c (testCapsInit): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-14 12:56:13 +00:00
false, false)) == NULL)
return NULL;
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_I686,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
goto error;
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_X86_64,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
goto error;
if (virTestGetDebug()) {
char *caps_str;
caps_str = virCapabilitiesFormatXML(caps);
if (!caps_str)
goto error;
VIR_TEST_DEBUG("LXC driver capabilities:\n%s", caps_str);
VIR_FREE(caps_str);
}
return caps;
error:
virObjectUnref(caps);
return NULL;
}
virLXCDriverPtr
testLXCDriverInit(void)
{
virLXCDriverPtr driver = g_new0(virLXCDriver, 1);
if (virMutexInit(&driver->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", "cannot initialize mutex");
g_free(driver);
return NULL;
}
driver->caps = testLXCCapsInit();
driver->xmlopt = lxcDomainXMLConfInit(driver);
return driver;
}
void
testLXCDriverFree(virLXCDriverPtr driver)
{
virObjectUnref(driver->xmlopt);
virObjectUnref(driver->caps);
virMutexDestroy(&driver->lock);
g_free(driver);
}
#endif