2012-03-26 21:09:31 +04:00
# include <config.h>
# ifdef WITH_LXC
# include "testutilslxc.h"
# include "testutils.h"
# include "domain_conf.h"
2019-12-03 13:49:49 +03:00
# define VIR_FROM_THIS VIR_FROM_LXC
2012-03-26 21:09:31 +04:00
2021-03-11 10:16:13 +03:00
virCaps *
2019-12-03 13:49:49 +03:00
testLXCCapsInit ( void )
2014-03-18 12:13:43 +04:00
{
2021-11-08 14:44:11 +03:00
g_autoptr ( virCaps ) caps = NULL ;
2021-03-11 10:16:13 +03:00
virCapsGuest * guest ;
2012-03-26 21:09:31 +04:00
2021-11-08 14:44:11 +03:00
if ( ( caps = virCapabilitiesNew ( VIR_ARCH_X86_64 , false , false ) ) = = NULL )
2012-03-26 21:09:31 +04:00
return NULL ;
2021-10-07 11:47:27 +03:00
guest = virCapabilitiesAddGuest ( caps , VIR_DOMAIN_OSTYPE_EXE ,
VIR_ARCH_I686 ,
" /usr/libexec/libvirt_lxc " , NULL ,
0 , NULL ) ;
2012-03-26 21:09:31 +04:00
2021-10-07 11:47:28 +03:00
virCapabilitiesAddGuestDomain ( guest , VIR_DOMAIN_VIRT_LXC , NULL , NULL , 0 , NULL ) ;
2012-03-26 21:09:31 +04:00
2021-10-07 11:47:27 +03:00
guest = virCapabilitiesAddGuest ( caps , VIR_DOMAIN_OSTYPE_EXE ,
VIR_ARCH_X86_64 ,
" /usr/libexec/libvirt_lxc " , NULL ,
0 , NULL ) ;
2012-03-26 21:09:31 +04:00
2021-10-07 11:47:28 +03:00
virCapabilitiesAddGuestDomain ( guest , VIR_DOMAIN_VIRT_LXC , NULL , NULL , 0 , NULL ) ;
2012-03-26 21:09:31 +04:00
if ( virTestGetDebug ( ) ) {
2021-11-08 14:44:11 +03:00
g_autofree char * caps_str = virCapabilitiesFormatXML ( caps ) ;
2012-03-26 21:09:31 +04:00
if ( ! caps_str )
2021-11-08 14:44:11 +03:00
return NULL ;
2012-03-26 21:09:31 +04:00
2015-04-23 20:38:00 +03:00
VIR_TEST_DEBUG ( " LXC driver capabilities: \n %s " , caps_str ) ;
2012-03-26 21:09:31 +04:00
}
2021-11-08 14:44:11 +03:00
return g_steal_pointer ( & caps ) ;
2012-03-26 21:09:31 +04:00
}
2019-12-03 13:49:49 +03:00
2021-03-11 10:16:13 +03:00
virLXCDriver *
2019-12-03 13:49:49 +03:00
testLXCDriverInit ( void )
{
2021-03-11 10:16:13 +03:00
virLXCDriver * driver = g_new0 ( virLXCDriver , 1 ) ;
2019-12-03 13:49:49 +03:00
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 21:55:24 +03:00
driver - > xmlopt = lxcDomainXMLConfInit ( driver , NULL ) ;
2019-12-03 13:49:49 +03:00
return driver ;
}
void
2021-03-11 10:16:13 +03:00
testLXCDriverFree ( virLXCDriver * driver )
2019-12-03 13:49:49 +03:00
{
virObjectUnref ( driver - > xmlopt ) ;
virObjectUnref ( driver - > caps ) ;
virMutexDestroy ( & driver - > lock ) ;
g_free ( driver ) ;
}
2012-03-26 21:09:31 +04:00
# endif