2012-03-26 17:09:31 +00:00
|
|
|
#include <config.h>
|
|
|
|
#ifdef WITH_LXC
|
|
|
|
|
|
|
|
# include "testutilslxc.h"
|
|
|
|
# include "testutils.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
# include "viralloc.h"
|
2012-03-26 17:09:31 +00:00
|
|
|
# include "domain_conf.h"
|
|
|
|
|
2019-12-03 10:49:49 +00:00
|
|
|
# define VIR_FROM_THIS VIR_FROM_LXC
|
2012-03-26 17:09:31 +00:00
|
|
|
|
2019-12-03 10:49:49 +00:00
|
|
|
virCapsPtr
|
|
|
|
testLXCCapsInit(void)
|
2014-03-18 08:13:43 +00:00
|
|
|
{
|
2012-03-26 17:09:31 +00:00
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
|
2012-12-18 19:32:23 +00:00
|
|
|
if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64,
|
2014-07-14 12:56:13 +00:00
|
|
|
false, false)) == NULL)
|
2012-03-26 17:09:31 +00:00
|
|
|
return NULL;
|
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
|
|
|
VIR_ARCH_I686,
|
2012-03-26 17:09:31 +00:00
|
|
|
"/usr/libexec/libvirt_lxc", NULL,
|
|
|
|
0, NULL)) == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2015-04-17 22:38:10 +00:00
|
|
|
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
|
2012-03-26 17:09:31 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
|
|
|
VIR_ARCH_X86_64,
|
2012-03-26 17:09:31 +00:00
|
|
|
"/usr/libexec/libvirt_lxc", NULL,
|
|
|
|
0, NULL)) == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2015-04-17 22:38:10 +00:00
|
|
|
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_LXC, NULL, NULL, 0, NULL))
|
2012-03-26 17:09:31 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
|
|
if (virTestGetDebug()) {
|
|
|
|
char *caps_str;
|
|
|
|
|
|
|
|
caps_str = virCapabilitiesFormatXML(caps);
|
|
|
|
if (!caps_str)
|
|
|
|
goto error;
|
|
|
|
|
2015-04-23 17:38:00 +00:00
|
|
|
VIR_TEST_DEBUG("LXC driver capabilities:\n%s", caps_str);
|
2012-03-26 17:09:31 +00:00
|
|
|
|
|
|
|
VIR_FREE(caps_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
|
2014-03-25 06:53:44 +00:00
|
|
|
error:
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(caps);
|
2012-03-26 17:09:31 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-12-03 10:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
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();
|
2020-12-03 18:55:24 +00:00
|
|
|
driver->xmlopt = lxcDomainXMLConfInit(driver, NULL);
|
2019-12-03 10:49:49 +00:00
|
|
|
|
|
|
|
return driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
testLXCDriverFree(virLXCDriverPtr driver)
|
|
|
|
{
|
|
|
|
virObjectUnref(driver->xmlopt);
|
|
|
|
virObjectUnref(driver->caps);
|
|
|
|
virMutexDestroy(&driver->lock);
|
|
|
|
g_free(driver);
|
|
|
|
}
|
|
|
|
|
2012-03-26 17:09:31 +00:00
|
|
|
#endif
|