static char *lxcConnectGetCapabilities(virConnectPtr conn) {
virLXCDriverPtr driver = conn->privateData;
+ virCapsPtr caps;
char *xml;
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
return NULL;
lxcDriverLock(driver);
- if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
+ if (!(caps = virLXCDriverGetCapabilities(driver, false))) {
+ lxcDriverUnlock(driver);
+ return NULL;
+ }
+
+ if ((xml = virCapabilitiesFormatXML(caps)) == NULL)
virReportOOMError();
lxcDriverUnlock(driver);
+ virObjectUnref(caps);
return xml;
}
virDomainEventPtr event = NULL;
virDomainDefPtr oldDef = NULL;
virLXCDriverConfigPtr cfg = NULL;
+ virCapsPtr caps = NULL;
lxcDriverLock(driver);
cfg = virLXCDriverGetConfig(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
1 << VIR_DOMAIN_VIRT_LXC,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
virObjectUnlock(vm);
if (event)
virDomainEventStateQueue(driver->domainEventState, event);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return dom;
unsigned int flags) {
virLXCDriverPtr driver = conn->privateData;
virDomainObjPtr vm = NULL;
- virDomainDefPtr def;
+ virDomainDefPtr def = NULL;
virDomainPtr dom = NULL;
virDomainEventPtr event = NULL;
virLXCDriverConfigPtr cfg = NULL;
+ virCapsPtr caps = NULL;
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
lxcDriverLock(driver);
cfg = virLXCDriverGetConfig(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
1 << VIR_DOMAIN_VIRT_LXC,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
virObjectUnlock(vm);
if (event)
virDomainEventStateQueue(driver->domainEventState, event);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return dom;
virSecurityModelPtr secmodel)
{
virLXCDriverPtr driver = conn->privateData;
+ virCapsPtr caps = NULL;
int ret = 0;
lxcDriverLock(driver);
if (virNodeGetSecurityModelEnsureACL(conn) < 0)
goto cleanup;
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
/* we treat no driver as success, but simply return no data in *secmodel */
- if (driver->caps->host.nsecModels == 0
- || driver->caps->host.secModels[0].model == NULL)
+ if (caps->host.nsecModels == 0
+ || caps->host.secModels[0].model == NULL)
goto cleanup;
- if (!virStrcpy(secmodel->model, driver->caps->host.secModels[0].model,
+ if (!virStrcpy(secmodel->model, caps->host.secModels[0].model,
VIR_SECURITY_MODEL_BUFLEN)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security model string exceeds max %d bytes"),
goto cleanup;
}
- if (!virStrcpy(secmodel->doi, driver->caps->host.secModels[0].doi,
+ if (!virStrcpy(secmodel->doi, caps->host.secModels[0].doi,
VIR_SECURITY_DOI_BUFLEN)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security DOI string exceeds max %d bytes"),
}
cleanup:
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
return ret;
}
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
+ virCapsPtr caps = NULL;
char *ld;
virLXCDriverConfigPtr cfg = NULL;
if ((lxc_driver->activeUsbHostdevs = virUSBDeviceListNew()) == NULL)
goto cleanup;
- if ((lxc_driver->caps = lxcCapsInit(lxc_driver)) == NULL)
+ if ((virLXCDriverGetCapabilities(lxc_driver, true)) == NULL)
goto cleanup;
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit()))
if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
goto cleanup;
+ if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false)))
+ goto cleanup;
+
/* Get all the running persistent or transient configs first */
if (virDomainObjListLoadAllConfigs(lxc_driver->domains,
cfg->stateDir,
NULL, 1,
- lxc_driver->caps,
+ caps,
lxc_driver->xmlopt,
1 << VIR_DOMAIN_VIRT_LXC,
NULL, NULL) < 0)
if (virDomainObjListLoadAllConfigs(lxc_driver->domains,
cfg->configDir,
cfg->autostartDir, 0,
- lxc_driver->caps,
+ caps,
lxc_driver->xmlopt,
1 << VIR_DOMAIN_VIRT_LXC,
NULL, NULL) < 0)
return 0;
cleanup:
+ virObjectUnref(caps);
lxcDriverUnlock(lxc_driver);
lxcStateCleanup();
return -1;
static int
lxcStateReload(void) {
virLXCDriverConfigPtr cfg = NULL;
+ virCapsPtr caps = NULL;
if (!lxc_driver)
return 0;
lxcDriverLock(lxc_driver);
+ if (!(caps = virLXCDriverGetCapabilities(lxc_driver, false))) {
+ lxcDriverUnlock(lxc_driver);
+ return -1;
+ }
+
cfg = virLXCDriverGetConfig(lxc_driver);
virDomainObjListLoadAllConfigs(lxc_driver->domains,
cfg->configDir,
cfg->autostartDir, 0,
- lxc_driver->caps,
+ caps,
lxc_driver->xmlopt,
1 << VIR_DOMAIN_VIRT_LXC,
lxcNotifyLoadDomain, lxc_driver);
lxcDriverUnlock(lxc_driver);
+ virObjectUnref(caps);
virObjectUnref(cfg);
return 0;
}
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
- if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &vmdef) < 0)
goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
- vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt);
+ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef)
goto cleanup;
}
virDomainDefFree(vmdef);
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef;
unsigned long long shares = 0;
cpu_bw_status = !!rc;
}
- if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &persistentDef) < 0)
goto cleanup;
cleanup:
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
return ret;
}
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
- if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &persistentDef) < 0)
goto cleanup;
cleanup:
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
goto cleanup;
}
- if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt,
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &persistentDef) < 0)
goto cleanup;
cleanup:
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
return ret;
}
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
}
}
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify device on transient domain"));
}
dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
- driver->caps, driver->xmlopt,
+ caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE);
if (dev == NULL)
goto cleanup;
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
- driver->caps, driver->xmlopt);
+ caps, driver->xmlopt);
if (!dev_copy)
goto cleanup;
}
goto cleanup;
/* Make a copy for updated domain. */
- vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt);
+ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef)
goto cleanup;
if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0)
virDomainDeviceDefFree(dev);
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
goto cleanup;
}
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
- driver->caps, driver->xmlopt,
+ caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE);
if (dev == NULL)
goto cleanup;
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
- driver->caps, driver->xmlopt);
+ caps, driver->xmlopt);
if (!dev_copy)
goto cleanup;
}
goto cleanup;
/* Make a copy for updated domain. */
- vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt);
+ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef)
goto cleanup;
if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0)
virDomainDeviceDefFree(dev);
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return ret;
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
+ virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
goto cleanup;
}
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
- driver->caps, driver->xmlopt,
+ caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE);
if (dev == NULL)
goto cleanup;
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
- driver->caps, driver->xmlopt);
+ caps, driver->xmlopt);
if (!dev_copy)
goto cleanup;
}
goto cleanup;
/* Make a copy for updated domain. */
- vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt);
+ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef)
goto cleanup;
virDomainDeviceDefFree(dev);
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
lxcDriverUnlock(driver);
virObjectUnref(cfg);
return ret;