mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: don't use passed in caps in post parse method
To enable the virCapsPtr parameter to the post parse method to be eliminated, the drivers must fetch the virCapsPtr from their own driver via the opaque parameter, or use an alternative approach to validate the parsed data. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
#include "testutilshostcpus.h"
|
||||
#include "domain_conf.h"
|
||||
|
||||
virCapsPtr
|
||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||
|
||||
static virCapsPtr
|
||||
testXLInitCaps(void)
|
||||
{
|
||||
virCapsPtr caps;
|
||||
@@ -79,3 +81,33 @@ testXLInitCaps(void)
|
||||
virObjectUnref(caps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
libxlDriverPrivatePtr testXLInitDriver(void)
|
||||
{
|
||||
libxlDriverPrivatePtr driver = g_new0(libxlDriverPrivate, 1);
|
||||
|
||||
if (virMutexInit(&driver->lock) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", "cannot initialize mutex");
|
||||
g_free(driver);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driver->config = libxlDriverConfigNew();
|
||||
|
||||
driver->config->caps = testXLInitCaps();
|
||||
|
||||
driver->xmlopt = libxlCreateXMLConf(driver);
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
void testXLFreeDriver(libxlDriverPrivatePtr driver)
|
||||
{
|
||||
virObjectUnref(driver->config->caps);
|
||||
virObjectUnref(driver->config);
|
||||
virObjectUnref(driver->xmlopt);
|
||||
virMutexDestroy(&driver->lock);
|
||||
g_free(driver);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user