conf: drop virCapsPtr param from domain APIs for copying config

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-11-27 12:41:59 +00:00
parent bf9d812956
commit 24d87d2e88
13 changed files with 42 additions and 78 deletions

View File

@ -3678,8 +3678,7 @@ virDomainObjWaitUntil(virDomainObjPtr vm,
* @return 0 on success, -1 on failure
*/
int
virDomainObjSetDefTransient(virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr domain,
void *parseOpaque)
{
@ -3691,7 +3690,7 @@ virDomainObjSetDefTransient(virCapsPtr caps,
if (domain->newDef)
return 0;
if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt,
if (!(domain->newDef = virDomainDefCopy(domain->def, xmlopt,
parseOpaque, false)))
goto out;
@ -3729,13 +3728,12 @@ virDomainObjRemoveTransientDef(virDomainObjPtr domain)
* @return NULL on error, virDOmainDefPtr on success
*/
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr domain,
void *parseOpaque)
{
if (virDomainObjIsActive(domain) &&
virDomainObjSetDefTransient(caps, xmlopt, domain, parseOpaque) < 0)
virDomainObjSetDefTransient(xmlopt, domain, parseOpaque) < 0)
return NULL;
if (domain->newDef)
@ -29352,7 +29350,6 @@ virDomainUSBDeviceDefForeach(virDomainDefPtr def,
* snapshots). */
virDomainDefPtr
virDomainDefCopy(virDomainDefPtr src,
virCapsPtr caps G_GNUC_UNUSED,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque,
bool migratable)
@ -29374,14 +29371,13 @@ virDomainDefCopy(virDomainDefPtr src,
virDomainDefPtr
virDomainObjCopyPersistentDef(virDomainObjPtr dom,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque)
{
virDomainDefPtr cur;
cur = virDomainObjGetPersistentDef(caps, xmlopt, dom, parseOpaque);
return virDomainDefCopy(cur, caps, xmlopt, parseOpaque, false);
cur = virDomainObjGetPersistentDef(xmlopt, dom, parseOpaque);
return virDomainDefCopy(cur, xmlopt, parseOpaque, false);
}
@ -29826,7 +29822,6 @@ virDomainNetFindByName(virDomainDefPtr def,
virDomainDeviceDefPtr
virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
const virDomainDef *def,
virCapsPtr caps G_GNUC_UNUSED,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque)
{

View File

@ -2898,7 +2898,6 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def);
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
const virDomainDef *def,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque);
virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device);
@ -2939,14 +2938,12 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
virDomainDefPtr def,
bool live,
virDomainDefPtr *oldDef);
int virDomainObjSetDefTransient(virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
int virDomainObjSetDefTransient(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr domain,
void *parseOpaque);
void virDomainObjRemoveTransientDef(virDomainObjPtr domain);
virDomainDefPtr
virDomainObjGetPersistentDef(virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
virDomainObjGetPersistentDef(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr domain,
void *parseOpaque);
@ -2963,12 +2960,10 @@ virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque,
bool migratable);
virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt,
void *parseOpaque);

View File

@ -1322,7 +1322,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
VIR_FREE(managed_save_path);
}
if (virDomainObjSetDefTransient(cfg->caps, driver->xmlopt, vm, NULL) < 0)
if (virDomainObjSetDefTransient(driver->xmlopt, vm, NULL) < 0)
goto cleanup;
/* Run an early hook to set-up missing devices */
@ -1550,8 +1550,8 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr driver,
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
bool ret = false;
if (!(migratableDefSrc = virDomainDefCopy(src, cfg->caps, driver->xmlopt, NULL, true)) ||
!(migratableDefDst = virDomainDefCopy(dst, cfg->caps, driver->xmlopt, NULL, true)))
if (!(migratableDefSrc = virDomainDefCopy(src, driver->xmlopt, NULL, true)) ||
!(migratableDefDst = virDomainDefCopy(dst, driver->xmlopt, NULL, true)))
goto cleanup;
ret = virDomainDefCheckABIStability(migratableDefSrc,

View File

@ -1601,7 +1601,7 @@ libxlDomainGetMaxMemory(virDomainPtr dom)
* domain configuration if needed. Return -1 on error.
*/
static int
virDomainLiveConfigHelperMethod(virCapsPtr caps,
virDomainLiveConfigHelperMethod(virCapsPtr caps G_GNUC_UNUSED,
virDomainXMLOptionPtr xmlopt,
virDomainObjPtr dom,
unsigned int *flags,
@ -1611,7 +1611,7 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps,
return -1;
if (*flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (!(*persistentDef = virDomainObjGetPersistentDef(caps, xmlopt, dom, NULL))) {
if (!(*persistentDef = virDomainObjGetPersistentDef(xmlopt, dom, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Get persistent config failed"));
return -1;
@ -2298,7 +2298,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
if (!(def = virDomainObjGetPersistentDef(cfg->caps, driver->xmlopt, vm, NULL)))
if (!(def = virDomainObjGetPersistentDef(driver->xmlopt, vm, NULL)))
goto endjob;
maplen = VIR_CPU_MAPLEN(nvcpus);
@ -4121,8 +4121,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
goto endjob;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg->caps,
driver->xmlopt, NULL)))
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL)))
goto endjob;
if (libxlDomainAttachDeviceConfig(vmdef, dev) < 0)
@ -4211,8 +4210,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
goto endjob;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg->caps,
driver->xmlopt, NULL)))
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL)))
goto endjob;
if (libxlDomainDetachDeviceConfig(vmdef, dev) < 0)
@ -4298,8 +4296,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg->caps,
driver->xmlopt, NULL)))
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL)))
goto cleanup;
if ((ret = libxlDomainUpdateDeviceConfig(vmdef, dev)) < 0)

View File

@ -1321,8 +1321,7 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn,
virDomainDefPtr vmdef;
vm->persistent = 1;
if (!(vmdef = virDomainObjGetPersistentDef(cfg->caps,
driver->xmlopt, vm, NULL)))
if (!(vmdef = virDomainObjGetPersistentDef(driver->xmlopt, vm, NULL)))
goto cleanup;
if (virDomainDefSave(vmdef, driver->xmlopt, cfg->caps, cfg->configDir) < 0)

View File

@ -1907,7 +1907,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (persistentDef) {
/* Make a copy for updated domain. */
persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, NULL);
persistentDefCopy = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL);
if (!persistentDefCopy)
goto endjob;
}
@ -4673,7 +4673,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
@ -4692,9 +4691,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
goto cleanup;
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
goto endjob;
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
goto endjob;
@ -4711,14 +4707,14 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
caps, driver->xmlopt, NULL);
driver->xmlopt, NULL);
if (!dev_copy)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, NULL);
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL);
if (!vmdef)
goto endjob;
@ -4768,7 +4764,6 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
virDomainDeviceDefFree(dev_copy);
virDomainDeviceDefFree(dev);
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
}
@ -4787,7 +4782,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
unsigned int flags)
{
virLXCDriverPtr driver = dom->conn->privateData;
virCapsPtr caps = NULL;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
virDomainDeviceDefPtr dev = NULL;
@ -4815,15 +4809,12 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
goto endjob;
}
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
goto endjob;
if (!(dev = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto endjob;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, NULL)))
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL)))
goto endjob;
/* virDomainDefCompatibleDevice call is delayed until we know the
@ -4845,7 +4836,6 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
virDomainDefFree(vmdef);
virDomainDeviceDefFree(dev);
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virObjectUnref(cfg);
return ret;
}
@ -4895,14 +4885,14 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
caps, driver->xmlopt, NULL);
driver->xmlopt, NULL);
if (!dev_copy)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, NULL);
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, NULL);
if (!vmdef)
goto endjob;

View File

@ -1266,7 +1266,7 @@ int virLXCProcessStart(virConnectPtr conn,
* report implicit runtime defaults in the XML, like vnc listen/socket
*/
VIR_DEBUG("Setting current domain def as transient");
if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, NULL) < 0)
if (virDomainObjSetDefTransient(driver->xmlopt, vm, NULL) < 0)
goto cleanup;
/* Run an early hook to set-up missing devices */

View File

@ -9034,17 +9034,13 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
{
int ret = -1;
virDomainDefPtr copy = NULL;
virCapsPtr caps = NULL;
virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS | VIR_DOMAIN_XML_UPDATE_CPU, -1);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE)))
goto format;
if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt, qemuCaps,
if (!(copy = virDomainDefCopy(def, driver->xmlopt, qemuCaps,
flags & VIR_DOMAIN_XML_MIGRATABLE)))
goto cleanup;
@ -9218,7 +9214,6 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
cleanup:
virDomainDefFree(copy);
virObjectUnref(caps);
return ret;
}

View File

@ -8622,7 +8622,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
* rely on the correct vm->def or vm->newDef being passed, so call the
* device parse based on which definition is in use */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt,
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt,
priv->qemuCaps);
if (!vmdef)
goto cleanup;
@ -8791,7 +8791,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
* create a deep copy of device as adding
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps,
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
driver->xmlopt, priv->qemuCaps);
if (!dev_copy)
goto endjob;
@ -8799,7 +8799,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt,
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt,
priv->qemuCaps);
if (!vmdef)
goto endjob;
@ -8888,7 +8888,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
* create a deep copy of device as adding
* to CONFIG takes one instance.
*/
dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps,
dev_copy = virDomainDeviceDefCopy(dev, vm->def,
driver->xmlopt, priv->qemuCaps);
if (!dev_copy)
goto cleanup;
@ -8896,7 +8896,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt, priv->qemuCaps);
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps);
if (!vmdef)
goto cleanup;
@ -8977,7 +8977,7 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
if (persistentDef) {
virDomainDeviceDef dev;
if (!(vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt,
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt,
priv->qemuCaps)))
goto cleanup;
@ -10580,7 +10580,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (persistentDef) {
/* Make a copy for updated domain. */
if (!(persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps,
if (!(persistentDefCopy = virDomainObjCopyPersistentDef(vm,
driver->xmlopt,
priv->qemuCaps)))
goto endjob;
@ -15955,7 +15955,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
goto endjob;
if (vm->newDef) {
def->parent.inactiveDom = virDomainDefCopy(vm->newDef, caps,
def->parent.inactiveDom = virDomainDefCopy(vm->newDef,
driver->xmlopt, priv->qemuCaps, true);
if (!def->parent.inactiveDom)
goto endjob;
@ -16483,7 +16483,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virDomainDefPtr config = NULL;
virDomainDefPtr inactiveConfig = NULL;
g_autoptr(virQEMUDriverConfig) cfg = NULL;
g_autoptr(virCaps) caps = NULL;
bool was_stopped = false;
qemuDomainSaveCookiePtr cookie;
virCPUDefPtr origCPU = NULL;
@ -16520,9 +16519,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (virDomainRevertToSnapshotEnsureACL(snapshot->domain->conn, vm->def) < 0)
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (qemuDomainHasBlockjob(vm, false)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain has active block job"));
@ -16574,14 +16570,14 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
if (snap->def->dom) {
config = virDomainDefCopy(snap->def->dom, caps,
config = virDomainDefCopy(snap->def->dom,
driver->xmlopt, priv->qemuCaps, true);
if (!config)
goto endjob;
}
if (snap->def->inactiveDom) {
inactiveConfig = virDomainDefCopy(snap->def->inactiveDom, caps,
inactiveConfig = virDomainDefCopy(snap->def->inactiveDom,
driver->xmlopt, priv->qemuCaps, true);
if (!inactiveConfig)
goto endjob;
@ -16594,7 +16590,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
*/
if (snapdef->state == VIR_DOMAIN_SNAPSHOT_RUNNING ||
snapdef->state == VIR_DOMAIN_SNAPSHOT_PAUSED) {
inactiveConfig = virDomainDefCopy(snap->def->dom, caps,
inactiveConfig = virDomainDefCopy(snap->def->dom,
driver->xmlopt, priv->qemuCaps, true);
if (!inactiveConfig)
goto endjob;

View File

@ -4852,7 +4852,7 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver,
oldDef = vm->newDef;
vm->newDef = qemuMigrationCookieGetPersistent(mig);
if (!(vmdef = virDomainObjGetPersistentDef(caps, driver->xmlopt, vm,
if (!(vmdef = virDomainObjGetPersistentDef(driver->xmlopt, vm,
priv->qemuCaps)))
goto error;

View File

@ -5600,7 +5600,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
* report implicit runtime defaults in the XML, like vnc listen/socket
*/
VIR_DEBUG("Setting current domain def as transient");
if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, priv->qemuCaps) < 0)
if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < 0)
goto cleanup;
if (flags & VIR_QEMU_PROCESS_START_PRETEND) {

View File

@ -696,8 +696,7 @@ testDomainStartState(testDriverPtr privconn,
virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason);
dom->def->id = virAtomicIntAdd(&privconn->nextDomID, 1);
if (virDomainObjSetDefTransient(privconn->caps,
privconn->xmlopt,
if (virDomainObjSetDefTransient(privconn->xmlopt,
dom, NULL) < 0) {
goto cleanup;
}
@ -8571,7 +8570,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
} else {
if (!(def->parent.dom = virDomainDefCopy(vm->def,
privconn->caps,
privconn->xmlopt,
NULL,
true)))
@ -8794,7 +8792,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
config = virDomainDefCopy(snap->def->dom, privconn->caps,
config = virDomainDefCopy(snap->def->dom,
privconn->xmlopt, NULL, true);
if (!config)
goto cleanup;
@ -9027,7 +9025,6 @@ testDomainCheckpointCreateXML(virDomainPtr domain,
goto cleanup;
} else {
if (!(def->parent.dom = virDomainDefCopy(vm->def,
privconn->caps,
privconn->xmlopt,
NULL,
true)))

View File

@ -427,7 +427,7 @@ testQemuHotplugCpuPrepare(const char *test,
/* create vm->newDef */
data->vm->persistent = true;
if (virDomainObjSetDefTransient(caps, driver.xmlopt, data->vm, NULL) < 0)
if (virDomainObjSetDefTransient(driver.xmlopt, data->vm, NULL) < 0)
goto error;
priv = data->vm->privateData;