mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00: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:
parent
2578d74aee
commit
4a4132b462
@ -20,6 +20,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bhyve_driver.h"
|
||||
#include "bhyve_conf.h"
|
||||
#include "bhyve_device.h"
|
||||
#include "bhyve_domain.h"
|
||||
@ -74,11 +75,16 @@ bhyveDomainDefNeedsISAController(virDomainDefPtr def)
|
||||
|
||||
static int
|
||||
bhyveDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr _caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
bhyveConnPtr driver = opaque;
|
||||
g_autoptr(virCaps) caps = bhyveDriverGetCapabilities(driver);
|
||||
if (!caps)
|
||||
return -1;
|
||||
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
|
@ -928,7 +928,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
if (!priv->caps)
|
||||
goto cleanup;
|
||||
|
||||
if (!(priv->xmlopt = virVMXDomainXMLConfInit()))
|
||||
if (!(priv->xmlopt = virVMXDomainXMLConfInit(priv->caps)))
|
||||
goto cleanup;
|
||||
|
||||
conn->privateData = priv;
|
||||
|
@ -2470,8 +2470,9 @@ libxlBuildDomainConfig(virPortAllocatorRangePtr graphicsports,
|
||||
}
|
||||
|
||||
virDomainXMLOptionPtr
|
||||
libxlCreateXMLConf(void)
|
||||
libxlCreateXMLConf(libxlDriverPrivatePtr driver)
|
||||
{
|
||||
libxlDomainDefParserConfig.priv = driver;
|
||||
return virDomainXMLOptionNew(&libxlDomainDefParserConfig,
|
||||
&libxlDomainXMLPrivateDataCallbacks,
|
||||
NULL, NULL, NULL);
|
||||
|
@ -207,7 +207,7 @@ libxlMakeUSB(virDomainHostdevDefPtr hostdev, libxl_device_usbdev *usbdev);
|
||||
#endif
|
||||
|
||||
virDomainXMLOptionPtr
|
||||
libxlCreateXMLConf(void);
|
||||
libxlCreateXMLConf(libxlDriverPrivatePtr driver);
|
||||
|
||||
#ifdef LIBXL_HAVE_DEVICE_CHANNEL
|
||||
# define LIBXL_ATTR_UNUSED
|
||||
|
@ -367,12 +367,15 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
|
||||
static int
|
||||
libxlDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
libxlDriverPrivatePtr driver = opaque;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
return -1;
|
||||
|
@ -769,7 +769,7 @@ libxlStateInitialize(bool privileged,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(libxl_driver->xmlopt = libxlCreateXMLConf()))
|
||||
if (!(libxl_driver->xmlopt = libxlCreateXMLConf(libxl_driver)))
|
||||
goto error;
|
||||
|
||||
/* Add Domain-0 */
|
||||
|
@ -207,8 +207,9 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
||||
|
||||
|
||||
virDomainXMLOptionPtr
|
||||
lxcDomainXMLConfInit(void)
|
||||
lxcDomainXMLConfInit(virLXCDriverPtr driver)
|
||||
{
|
||||
virLXCDriverDomainDefParserConfig.priv = driver;
|
||||
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
||||
&virLXCDriverPrivateDataCallbacks,
|
||||
&virLXCDriverDomainXMLNamespace,
|
||||
|
@ -112,7 +112,7 @@ int virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg,
|
||||
virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver);
|
||||
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
||||
bool refresh);
|
||||
virDomainXMLOptionPtr lxcDomainXMLConfInit(void);
|
||||
virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriverPtr driver);
|
||||
|
||||
static inline void lxcDriverLock(virLXCDriverPtr driver)
|
||||
{
|
||||
|
@ -159,11 +159,41 @@ static void virLXCControllerQuitTimer(int timer G_GNUC_UNUSED, void *opaque)
|
||||
}
|
||||
|
||||
|
||||
static virLXCDriverPtr
|
||||
virLXCControllerDriverNew(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 = virLXCDriverCapsInit(NULL);
|
||||
driver->xmlopt = lxcDomainXMLConfInit(driver);
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virLXCControllerDriverFree(virLXCDriverPtr driver)
|
||||
{
|
||||
if (!driver)
|
||||
return;
|
||||
virObjectUnref(driver->xmlopt);
|
||||
virObjectUnref(driver->caps);
|
||||
virMutexDestroy(&driver->lock);
|
||||
g_free(driver);
|
||||
}
|
||||
|
||||
|
||||
static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
{
|
||||
virLXCControllerPtr ctrl = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
virDomainXMLOptionPtr xmlopt = NULL;
|
||||
virLXCDriverPtr driver = NULL;
|
||||
char *configFile = NULL;
|
||||
|
||||
if (VIR_ALLOC(ctrl) < 0)
|
||||
@ -174,10 +204,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
|
||||
ctrl->name = g_strdup(name);
|
||||
|
||||
if (!(caps = virLXCDriverCapsInit(NULL)))
|
||||
goto error;
|
||||
|
||||
if (!(xmlopt = lxcDomainXMLConfInit()))
|
||||
if (!(driver = virLXCControllerDriverNew()))
|
||||
goto error;
|
||||
|
||||
if ((configFile = virDomainConfigFile(LXC_STATE_DIR,
|
||||
@ -185,7 +212,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
goto error;
|
||||
|
||||
if ((ctrl->vm = virDomainObjParseFile(configFile,
|
||||
caps, xmlopt,
|
||||
driver->caps, driver->xmlopt,
|
||||
0)) == NULL)
|
||||
goto error;
|
||||
ctrl->def = ctrl->vm->def;
|
||||
@ -197,8 +224,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(configFile);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
virLXCControllerDriverFree(driver);
|
||||
return ctrl;
|
||||
|
||||
error:
|
||||
|
@ -351,11 +351,15 @@ virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks = {
|
||||
|
||||
static int
|
||||
virLXCDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr _caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
virLXCDriverPtr driver = opaque;
|
||||
g_autoptr(virCaps) caps = virLXCDriverGetCapabilities(driver, false);
|
||||
if (!caps)
|
||||
return -1;
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
|
@ -1584,7 +1584,7 @@ static int lxcStateInitialize(bool privileged,
|
||||
if (!(caps = virLXCDriverGetCapabilities(lxc_driver, true)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit()))
|
||||
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
|
||||
|
@ -1082,12 +1082,13 @@ int openvzGetVEID(const char *name)
|
||||
|
||||
static int
|
||||
openvzDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
struct openvz_driver *driver = opaque;
|
||||
if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
return -1;
|
||||
@ -1133,8 +1134,9 @@ virDomainDefParserConfig openvzDomainDefParserConfig = {
|
||||
.features = VIR_DOMAIN_DEF_FEATURE_NAME_SLASH,
|
||||
};
|
||||
|
||||
virDomainXMLOptionPtr openvzXMLOption(void)
|
||||
virDomainXMLOptionPtr openvzXMLOption(struct openvz_driver *driver)
|
||||
{
|
||||
openvzDomainDefParserConfig.priv = driver;
|
||||
return virDomainXMLOptionNew(&openvzDomainDefParserConfig,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -63,4 +63,4 @@ int strtoI(const char *str);
|
||||
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
|
||||
int openvzGetVEID(const char *name);
|
||||
int openvzReadNetworkConf(virDomainDefPtr def, int veid);
|
||||
virDomainXMLOptionPtr openvzXMLOption(void);
|
||||
virDomainXMLOptionPtr openvzXMLOption(struct openvz_driver *driver);
|
||||
|
@ -1311,7 +1311,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn,
|
||||
if (!(driver->caps = openvzCapsInit()))
|
||||
goto cleanup;
|
||||
|
||||
if (!(driver->xmlopt = openvzXMLOption()))
|
||||
if (!(driver->xmlopt = openvzXMLOption(driver)))
|
||||
goto cleanup;
|
||||
|
||||
if (openvzLoadDomains(driver) < 0)
|
||||
|
@ -1062,12 +1062,13 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
|
||||
static int
|
||||
phypDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
phyp_driverPtr driver = opaque;
|
||||
if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
return -1;
|
||||
@ -1157,6 +1158,7 @@ phypConnectOpen(virConnectPtr conn,
|
||||
if ((phyp_driver->caps = phypCapsInit()) == NULL)
|
||||
goto failure;
|
||||
|
||||
virPhypDriverDomainDefParserConfig.priv = phyp_driver;
|
||||
if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig,
|
||||
NULL, NULL, NULL, NULL)))
|
||||
goto failure;
|
||||
|
@ -2094,6 +2094,44 @@ virQEMUCapsSetHostModel(virQEMUCapsPtr qemuCaps,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps,
|
||||
virArch arch)
|
||||
{
|
||||
if (arch == qemuCaps->arch)
|
||||
return true;
|
||||
|
||||
if (qemuCaps->arch == VIR_ARCH_X86_64 && arch == VIR_ARCH_I686)
|
||||
return true;
|
||||
|
||||
if (qemuCaps->arch == VIR_ARCH_AARCH64 && arch == VIR_ARCH_ARMV7L)
|
||||
return true;
|
||||
|
||||
if (qemuCaps->arch == VIR_ARCH_ARMV7L && arch == VIR_ARCH_ARMV6L)
|
||||
return true;
|
||||
|
||||
if (qemuCaps->arch == VIR_ARCH_PPC64 && arch == VIR_ARCH_PPC64LE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps,
|
||||
virDomainVirtType virtType)
|
||||
{
|
||||
if (virtType == VIR_DOMAIN_VIRT_QEMU)
|
||||
return true;
|
||||
|
||||
if (virtType == VIR_DOMAIN_VIRT_KVM &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
||||
virArch hostarch,
|
||||
|
@ -603,6 +603,10 @@ int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
|
||||
bool migratable,
|
||||
char ***features);
|
||||
|
||||
bool virQEMUCapsIsArchSupported(virQEMUCapsPtr qemuCaps,
|
||||
virArch arch);
|
||||
bool virQEMUCapsIsVirtTypeSupported(virQEMUCapsPtr qemuCaps,
|
||||
virDomainVirtType virtType);
|
||||
bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
||||
virArch hostarch,
|
||||
virDomainVirtType type,
|
||||
|
@ -4691,22 +4691,40 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def,
|
||||
|
||||
static int
|
||||
qemuDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags,
|
||||
void *opaque,
|
||||
void *parseOpaque)
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
/* Note that qemuCaps may be NULL when this function is called. This
|
||||
* function shall not fail in that case. It will be re-run on VM startup
|
||||
* with the capabilities populated. */
|
||||
virQEMUCapsPtr qemuCaps = parseOpaque;
|
||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
def->emulator))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (def->os.type != VIR_DOMAIN_OSTYPE_HVM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Emulator '%s' does not support os type '%s'"),
|
||||
def->emulator, virDomainOSTypeToString(def->os.type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virQEMUCapsIsArchSupported(qemuCaps, def->os.arch)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Emulator '%s' does not support arch '%s'"),
|
||||
def->emulator, virArchToString(def->os.arch));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, def->virtType)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Emulator '%s' does not support virt type '%s'"),
|
||||
def->emulator, virDomainVirtTypeToString(def->virtType));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->os.bootloader || def->os.bootloaderArgs) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -4715,15 +4733,9 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
if (!def->os.machine) {
|
||||
g_autofree virCapsDomainDataPtr capsdata = NULL;
|
||||
|
||||
if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType,
|
||||
NULL, NULL))) {
|
||||
return -1;
|
||||
}
|
||||
def->os.machine = g_strdup(capsdata->machinetype);
|
||||
const char *machine = virQEMUCapsGetPreferredMachine(qemuCaps,
|
||||
def->virtType);
|
||||
def->os.machine = g_strdup(machine);
|
||||
}
|
||||
|
||||
qemuDomainNVRAMPathGenerate(cfg, def);
|
||||
|
@ -117,12 +117,13 @@ vmwareDataFreeFunc(void *data)
|
||||
|
||||
static int
|
||||
vmwareDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
struct vmware_driver *driver = opaque;
|
||||
if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
return -1;
|
||||
@ -148,11 +149,11 @@ virDomainDefParserConfig vmwareDomainDefParserConfig = {
|
||||
};
|
||||
|
||||
static virDomainXMLOptionPtr
|
||||
vmwareDomainXMLConfigInit(void)
|
||||
vmwareDomainXMLConfigInit(struct vmware_driver *driver)
|
||||
{
|
||||
virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
|
||||
.free = vmwareDataFreeFunc };
|
||||
|
||||
vmwareDomainDefParserConfig.priv = driver;
|
||||
return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
@ -235,7 +236,7 @@ vmwareConnectOpen(virConnectPtr conn,
|
||||
if (!(driver->caps = vmwareCapsInit()))
|
||||
goto cleanup;
|
||||
|
||||
if (!(driver->xmlopt = vmwareDomainXMLConfigInit()))
|
||||
if (!(driver->xmlopt = vmwareDomainXMLConfigInit(driver)))
|
||||
goto cleanup;
|
||||
|
||||
if (vmwareLoadDomains(driver) < 0)
|
||||
|
@ -530,11 +530,12 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI,
|
||||
|
||||
static int
|
||||
virVMXDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr _caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
virCapsPtr caps = opaque;
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
@ -612,8 +613,9 @@ static virXMLNamespace virVMXDomainXMLNamespace = {
|
||||
};
|
||||
|
||||
virDomainXMLOptionPtr
|
||||
virVMXDomainXMLConfInit(void)
|
||||
virVMXDomainXMLConfInit(virCapsPtr caps)
|
||||
{
|
||||
virVMXDomainDefParserConfig.priv = caps;
|
||||
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL,
|
||||
&virVMXDomainXMLNamespace, NULL, NULL);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
typedef struct _virVMXContext virVMXContext;
|
||||
|
||||
virDomainXMLOptionPtr virVMXDomainXMLConfInit(void);
|
||||
virDomainXMLOptionPtr virVMXDomainXMLConfInit(virCapsPtr caps);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
|
@ -241,12 +241,13 @@ vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
|
||||
|
||||
static int
|
||||
vzDomainDefPostParse(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
virCapsPtr caps G_GNUC_UNUSED,
|
||||
unsigned int parseFlags G_GNUC_UNUSED,
|
||||
void *opaque G_GNUC_UNUSED,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virCapabilitiesDomainSupported(caps, def->os.type,
|
||||
vzDriverPtr driver = opaque;
|
||||
if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
|
||||
def->os.arch,
|
||||
def->virtType))
|
||||
return -1;
|
||||
@ -289,10 +290,12 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
static int
|
||||
vzDomainDeviceDefValidate(const virDomainDeviceDef *dev,
|
||||
const virDomainDef *def,
|
||||
void *opaque G_GNUC_UNUSED)
|
||||
void *opaque)
|
||||
{
|
||||
vzDriverPtr driver = opaque;
|
||||
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
|
||||
return vzCheckUnsupportedDisk(def, dev->data.disk, opaque);
|
||||
return vzCheckUnsupportedDisk(def, dev->data.disk, driver->vzCaps);
|
||||
else if (dev->type == VIR_DOMAIN_DEVICE_GRAPHICS)
|
||||
return vzCheckUnsupportedGraphics(dev->data.graphics);
|
||||
|
||||
@ -323,7 +326,7 @@ vzDriverObjNew(void)
|
||||
if (!(driver = virObjectLockableNew(vzDriverClass)))
|
||||
return NULL;
|
||||
|
||||
vzDomainDefParserConfig.priv = &driver->vzCaps;
|
||||
vzDomainDefParserConfig.priv = driver;
|
||||
|
||||
if (!(driver->caps = vzBuildCapabilities()) ||
|
||||
!(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
||||
|
@ -1048,11 +1048,17 @@ endif WITH_LXC
|
||||
if WITH_QEMU
|
||||
vircapstest_SOURCES += testutilsqemu.c testutilsqemu.h
|
||||
endif WITH_QEMU
|
||||
vircapstest_LDADD =
|
||||
if WITH_QEMU
|
||||
vircapstest_LDADD = $(qemu_LDADDS)
|
||||
else ! WITH_QEMU
|
||||
vircapstest_LDADD = $(LDADDS)
|
||||
endif ! WITH_QEMU
|
||||
vircapstest_LDADD += ../src/libvirt_driver_qemu_impl.la
|
||||
if WITH_DTRACE_PROBES
|
||||
vircapstest_LDADD += ../src/libvirt_qemu_probes.lo
|
||||
endif WITH_DTRACE_PROBES
|
||||
endif WITH_QEMU
|
||||
if WITH_LXC
|
||||
vircapstest_LDADD += ../src/libvirt_driver_lxc_impl.la
|
||||
endif WITH_LXC
|
||||
vircapstest_LDADD += $(LDADDS)
|
||||
|
||||
libdomaincapsmock_la_SOURCES = domaincapsmock.c
|
||||
libdomaincapsmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
# define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||
|
||||
static virCapsPtr caps;
|
||||
static libxlDriverPrivatePtr driver;
|
||||
|
||||
static int
|
||||
testCompareXMLToDomConfig(const char *xmlfile,
|
||||
@ -50,19 +50,13 @@ testCompareXMLToDomConfig(const char *xmlfile,
|
||||
int ret = -1;
|
||||
libxl_domain_config actualconfig;
|
||||
libxl_domain_config expectconfig;
|
||||
libxlDriverConfigPtr cfg;
|
||||
xentoollog_logger *log = NULL;
|
||||
virPortAllocatorRangePtr gports = NULL;
|
||||
virDomainXMLOptionPtr xmlopt = NULL;
|
||||
virDomainDefPtr vmdef = NULL;
|
||||
char *actualjson = NULL;
|
||||
char *tempjson = NULL;
|
||||
char *expectjson = NULL;
|
||||
|
||||
if (!(cfg = libxlDriverConfigNew()))
|
||||
return -1;
|
||||
|
||||
cfg->caps = caps;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
libxl_domain_config_init(&actualconfig);
|
||||
libxl_domain_config_init(&expectconfig);
|
||||
@ -82,10 +76,7 @@ testCompareXMLToDomConfig(const char *xmlfile,
|
||||
if (!(gports = virPortAllocatorRangeNew("vnc", 5900, 6000)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(xmlopt = libxlCreateXMLConf()))
|
||||
goto cleanup;
|
||||
|
||||
if (!(vmdef = virDomainDefParseFile(xmlfile, caps, xmlopt,
|
||||
if (!(vmdef = virDomainDefParseFile(xmlfile, cfg->caps, driver->xmlopt,
|
||||
NULL, VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
|
||||
@ -128,12 +119,9 @@ testCompareXMLToDomConfig(const char *xmlfile,
|
||||
VIR_FREE(tempjson);
|
||||
virDomainDefFree(vmdef);
|
||||
virPortAllocatorRangeFree(gports);
|
||||
virObjectUnref(xmlopt);
|
||||
libxl_domain_config_dispose(&actualconfig);
|
||||
libxl_domain_config_dispose(&expectconfig);
|
||||
xtl_logger_destroy(log);
|
||||
cfg->caps = NULL;
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -177,7 +165,7 @@ mymain(void)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if ((caps = testXLInitCaps()) == NULL)
|
||||
if ((driver = testXLInitDriver()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST(name) \
|
||||
@ -216,6 +204,8 @@ mymain(void)
|
||||
|
||||
unlink("libxl-driver.log");
|
||||
|
||||
testXLFreeDriver(driver);
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
# define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLOptionPtr xmlopt;
|
||||
static virLXCDriverPtr driver;
|
||||
|
||||
static int testSanitizeDef(virDomainDefPtr vmdef)
|
||||
{
|
||||
@ -34,7 +33,7 @@ testCompareXMLToConfigFiles(const char *xmlfile,
|
||||
if (virTestLoadFile(configfile, &config) < 0)
|
||||
goto fail;
|
||||
|
||||
vmdef = lxcParseConfigString(config, caps, xmlopt);
|
||||
vmdef = lxcParseConfigString(config, driver->caps, driver->xmlopt);
|
||||
if ((vmdef && expectError) || (!vmdef && !expectError))
|
||||
goto fail;
|
||||
|
||||
@ -42,7 +41,7 @@ testCompareXMLToConfigFiles(const char *xmlfile,
|
||||
if (testSanitizeDef(vmdef) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(actualxml = virDomainDefFormat(vmdef, xmlopt, caps, 0)))
|
||||
if (!(actualxml = virDomainDefFormat(vmdef, driver->xmlopt, driver->caps, 0)))
|
||||
goto fail;
|
||||
|
||||
if (virTestCompareToFile(actualxml, xmlfile) < 0)
|
||||
@ -109,14 +108,9 @@ mymain(void)
|
||||
{
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
if (!(caps = testLXCCapsInit()))
|
||||
if (!(driver = testLXCDriverInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = lxcDomainXMLConfInit())) {
|
||||
virObjectUnref(caps);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
# define DO_TEST(name, expectError) \
|
||||
do { \
|
||||
const struct testInfo info = { name, expectError }; \
|
||||
@ -166,8 +160,7 @@ mymain(void)
|
||||
DO_TEST3("blkiotune", false);
|
||||
DO_TEST3("ethernet", false);
|
||||
|
||||
virObjectUnref(xmlopt);
|
||||
virObjectUnref(caps);
|
||||
testLXCDriverFree(driver);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -16,8 +16,7 @@
|
||||
|
||||
# define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLOptionPtr xmlopt;
|
||||
static virLXCDriverPtr driver;
|
||||
|
||||
struct testInfo {
|
||||
const char *name;
|
||||
@ -39,7 +38,7 @@ testCompareXMLToXMLHelper(const void *data)
|
||||
xml_out = g_strdup_printf("%s/lxcxml2xmloutdata/lxc-%s.xml",
|
||||
abs_srcdir, info->name);
|
||||
|
||||
ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in,
|
||||
ret = testCompareDomXML2XMLFiles(driver->caps, driver->xmlopt, xml_in,
|
||||
info->different ? xml_out : xml_in,
|
||||
!info->inactive_only,
|
||||
info->parse_flags,
|
||||
@ -55,10 +54,7 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((caps = testLXCCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = lxcDomainXMLConfInit()))
|
||||
if (!(driver = testLXCDriverInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST_FULL(name, is_different, inactive, parse_flags) \
|
||||
@ -95,8 +91,7 @@ mymain(void)
|
||||
DO_TEST("initdir");
|
||||
DO_TEST("inituser");
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
testLXCDriverFree(driver);
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -98,7 +98,10 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
|
||||
" </interface>\n"
|
||||
" </devices>\n"
|
||||
"</domain>\n";
|
||||
virDomainXMLOptionPtr xmlopt = openvzXMLOption();
|
||||
struct openvz_driver driver = {0};
|
||||
|
||||
driver.xmlopt = openvzXMLOption(&driver);
|
||||
driver.caps = openvzCapsInit();
|
||||
|
||||
if (!(def = virDomainDefNew()))
|
||||
goto cleanup;
|
||||
@ -113,7 +116,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
actual = virDomainDefFormat(def, xmlopt, NULL, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
|
||||
actual = virDomainDefFormat(def, driver.xmlopt, driver.caps, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
|
||||
|
||||
if (actual == NULL) {
|
||||
fprintf(stderr, "ERROR: %s\n", virGetLastErrorMessage());
|
||||
@ -128,7 +131,8 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
|
||||
result = 0;
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(xmlopt);
|
||||
virObjectUnref(driver.xmlopt);
|
||||
virObjectUnref(driver.caps);
|
||||
VIR_FREE(actual);
|
||||
virDomainDefFree(def);
|
||||
|
||||
|
@ -6,8 +6,10 @@
|
||||
# include "viralloc.h"
|
||||
# include "domain_conf.h"
|
||||
|
||||
# define VIR_FROM_THIS VIR_FROM_LXC
|
||||
|
||||
virCapsPtr testLXCCapsInit(void)
|
||||
virCapsPtr
|
||||
testLXCCapsInit(void)
|
||||
{
|
||||
virCapsPtr caps;
|
||||
virCapsGuestPtr guest;
|
||||
@ -54,4 +56,34 @@ virCapsPtr testLXCCapsInit(void)
|
||||
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
|
||||
|
@ -18,7 +18,11 @@
|
||||
|
||||
#include "capabilities.h"
|
||||
|
||||
#include "lxc/lxc_conf.h"
|
||||
|
||||
#define FAKEDEVDIR0 "/fakedevdir0/bla/fasl"
|
||||
#define FAKEDEVDIR1 "/fakedevdir1/bla/fasl"
|
||||
|
||||
virCapsPtr testLXCCapsInit(void);
|
||||
virLXCDriverPtr testLXCDriverInit(void);
|
||||
void testLXCDriverFree(virLXCDriverPtr driver);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -18,7 +18,10 @@
|
||||
|
||||
#include "capabilities.h"
|
||||
#ifdef WITH_LIBXL
|
||||
# include "libxl/libxl_capabilities.h"
|
||||
#endif
|
||||
# include "libxl/libxl_conf.h"
|
||||
|
||||
virCapsPtr testXLInitCaps(void);
|
||||
libxlDriverPrivatePtr testXLInitDriver(void);
|
||||
|
||||
void testXLFreeDriver(libxlDriverPrivatePtr driver);
|
||||
|
||||
#endif /* WITH_LIBXL */
|
||||
|
@ -186,7 +186,7 @@ mymain(void)
|
||||
if (caps == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = virVMXDomainXMLConfInit()))
|
||||
if (!(xmlopt = virVMXDomainXMLConfInit(caps)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
ctx.opaque = NULL;
|
||||
|
@ -36,9 +36,7 @@
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLOptionPtr xmlopt;
|
||||
|
||||
static libxlDriverPrivatePtr driver;
|
||||
|
||||
/*
|
||||
* This function provides a mechanism to replace variables in test
|
||||
@ -74,6 +72,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
|
||||
int ret = -1;
|
||||
virDomainDefPtr def = NULL;
|
||||
char *replacedXML = NULL;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
if (VIR_ALLOC_N(gotxlcfgData, wrote) < 0)
|
||||
goto fail;
|
||||
@ -84,16 +83,16 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
|
||||
if (replaceVars) {
|
||||
if (!(replacedXML = testReplaceVarsXML(xml)))
|
||||
goto fail;
|
||||
if (!(def = virDomainDefParseString(replacedXML, caps, xmlopt,
|
||||
if (!(def = virDomainDefParseString(replacedXML, cfg->caps, driver->xmlopt,
|
||||
NULL, VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
} else {
|
||||
if (!(def = virDomainDefParseFile(xml, caps, xmlopt,
|
||||
if (!(def = virDomainDefParseFile(xml, cfg->caps, driver->xmlopt,
|
||||
NULL, VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
|
||||
if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) {
|
||||
fprintf(stderr, "ABI stability check failed on %s", xml);
|
||||
goto fail;
|
||||
}
|
||||
@ -133,6 +132,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
|
||||
virConnectPtr conn;
|
||||
virDomainDefPtr def = NULL;
|
||||
char *replacedXML = NULL;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
conn = virGetConnect();
|
||||
if (!conn) goto fail;
|
||||
@ -143,10 +143,10 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
|
||||
if (!(conf = virConfReadString(xlcfgData, 0)))
|
||||
goto fail;
|
||||
|
||||
if (!(def = xenParseXL(conf, caps, xmlopt)))
|
||||
if (!(def = xenParseXL(conf, cfg->caps, driver->xmlopt)))
|
||||
goto fail;
|
||||
|
||||
if (!(gotxml = virDomainDefFormat(def, xmlopt, caps,
|
||||
if (!(gotxml = virDomainDefFormat(def, driver->xmlopt, cfg->caps,
|
||||
VIR_DOMAIN_XML_INACTIVE |
|
||||
VIR_DOMAIN_XML_SECURE)))
|
||||
goto fail;
|
||||
@ -208,10 +208,7 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!(caps = testXLInitCaps()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = libxlCreateXMLConf()))
|
||||
if (!(driver = testXLInitDriver()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST_PARSE(name, replace) \
|
||||
@ -303,10 +300,9 @@ mymain(void)
|
||||
DO_TEST("usb");
|
||||
DO_TEST("usbctrl");
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
testXLFreeDriver(driver);
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
VIR_TEST_MAIN(mymain)
|
||||
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("xl"))
|
||||
|
@ -34,8 +34,7 @@
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLOptionPtr xmlopt;
|
||||
static libxlDriverPrivatePtr driver;
|
||||
|
||||
static int
|
||||
testCompareParseXML(const char *xmcfg, const char *xml)
|
||||
@ -46,6 +45,7 @@ testCompareParseXML(const char *xmcfg, const char *xml)
|
||||
virConnectPtr conn = NULL;
|
||||
int wrote = 4096;
|
||||
virDomainDefPtr def = NULL;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
if (VIR_ALLOC_N(gotxmcfgData, wrote) < 0)
|
||||
goto fail;
|
||||
@ -53,11 +53,11 @@ testCompareParseXML(const char *xmcfg, const char *xml)
|
||||
conn = virGetConnect();
|
||||
if (!conn) goto fail;
|
||||
|
||||
if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL,
|
||||
if (!(def = virDomainDefParseFile(xml, cfg->caps, driver->xmlopt, NULL,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
goto fail;
|
||||
|
||||
if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
|
||||
if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) {
|
||||
fprintf(stderr, "ABI stability check failed on %s", xml);
|
||||
goto fail;
|
||||
}
|
||||
@ -90,6 +90,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
|
||||
g_autoptr(virConf) conf = NULL;
|
||||
int ret = -1;
|
||||
virDomainDefPtr def = NULL;
|
||||
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
|
||||
|
||||
if (virTestLoadFile(xmcfg, &xmcfgData) < 0)
|
||||
goto fail;
|
||||
@ -97,10 +98,10 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
|
||||
if (!(conf = virConfReadString(xmcfgData, 0)))
|
||||
goto fail;
|
||||
|
||||
if (!(def = xenParseXM(conf, caps, xmlopt)))
|
||||
if (!(def = xenParseXM(conf, cfg->caps, driver->xmlopt)))
|
||||
goto fail;
|
||||
|
||||
if (!(gotxml = virDomainDefFormat(def, xmlopt, caps, VIR_DOMAIN_DEF_FORMAT_SECURE)))
|
||||
if (!(gotxml = virDomainDefFormat(def, driver->xmlopt, cfg->caps, VIR_DOMAIN_DEF_FORMAT_SECURE)))
|
||||
goto fail;
|
||||
|
||||
if (virTestCompareToFile(gotxml, xml) < 0)
|
||||
@ -152,10 +153,7 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!(caps = testXLInitCaps()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = libxlCreateXMLConf()))
|
||||
if (!(driver = testXLInitDriver()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST_PARSE(name) \
|
||||
@ -225,10 +223,9 @@ mymain(void)
|
||||
DO_TEST("disk-drv-blktap-raw");
|
||||
DO_TEST("disk-drv-blktap2-raw");
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
testXLFreeDriver(driver);
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
VIR_TEST_MAIN(mymain)
|
||||
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("xl"))
|
||||
|
@ -207,7 +207,7 @@ mymain(void)
|
||||
if (caps == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlopt = virVMXDomainXMLConfInit()))
|
||||
if (!(xmlopt = virVMXDomainXMLConfInit(caps)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
ctx.opaque = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user