提交 cd57b7c7 编写于 作者: J Joao Martins 提交者: Daniel P. Berrange

conf: add caps to virDomainSaveConfig

virDomainSaveConfig calls virDomainDefFormat which was setting the caps
to NULL, thus keeping the old behaviour (i.e. not looking at
netprefix). This patch adds the virCapsPtr to the function and allows
the configuration to be saved and skipping interface names that were
registered with virCapabilitiesSetNetPrefix().
Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
上级 d239a542
......@@ -551,7 +551,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
def = NULL;
vm->persistent = 1;
if (virDomainSaveConfig(BHYVE_CONFIG_DIR,
if (virDomainSaveConfig(BHYVE_CONFIG_DIR, caps,
vm->newDef ? vm->newDef : vm->def) < 0) {
virDomainObjListRemove(privconn->domains, vm);
vm = NULL;
......
......@@ -22725,12 +22725,13 @@ virDomainSaveXML(const char *configDir,
int
virDomainSaveConfig(const char *configDir,
virCapsPtr caps,
virDomainDefPtr def)
{
int ret = -1;
char *xml;
if (!(xml = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE)))
if (!(xml = virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECURE)))
goto cleanup;
if (virDomainSaveXML(configDir, def, xml))
......@@ -23914,7 +23915,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm,
uri) < 0)
return -1;
if (virDomainSaveConfig(configDir, persistentDef) < 0)
if (virDomainSaveConfig(configDir, caps, persistentDef) < 0)
return -1;
}
......
......@@ -2908,6 +2908,7 @@ int virDomainSaveXML(const char *configDir,
const char *xml);
int virDomainSaveConfig(const char *configDir,
virCapsPtr caps,
virDomainDefPtr def);
int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt,
const char *statusDir,
......
......@@ -1511,7 +1511,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
virDomainDefSetMemoryTotal(persistentDef, newmem);
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, persistentDef);
goto endjob;
}
......@@ -1543,7 +1543,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_MEM_CONFIG) {
sa_assert(persistentDef);
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, persistentDef);
goto endjob;
}
}
......@@ -2237,7 +2237,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
}
if (flags & VIR_DOMAIN_VCPU_CONFIG) {
if (virDomainSaveConfig(cfg->configDir, def) < 0) {
if (virDomainSaveConfig(cfg->configDir, cfg->caps, def) < 0) {
VIR_WARN("Unable to save configuration of vm %s after changing vcpus",
vm->def->name);
}
......@@ -2394,7 +2394,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
ret = virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm);
} else if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, targetDef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, targetDef);
}
endjob:
......@@ -2805,6 +2805,7 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
vm->persistent = 1;
if (virDomainSaveConfig(cfg->configDir,
cfg->caps,
vm->newDef ? vm->newDef : vm->def) < 0) {
virDomainObjListRemove(driver->domains, vm);
vm = NULL;
......@@ -3749,7 +3750,7 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -3857,7 +3858,7 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -3962,7 +3963,7 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
/* Finally, if no error until here, we can save config. */
if (!ret && (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......
......@@ -488,7 +488,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
def = NULL;
vm->persistent = 1;
if (virDomainSaveConfig(cfg->configDir,
if (virDomainSaveConfig(cfg->configDir, driver->caps,
vm->newDef ? vm->newDef : vm->def) < 0) {
virDomainObjListRemove(driver->domains, vm);
vm = NULL;
......@@ -737,7 +737,8 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
virDomainDefSetMemoryTotal(persistentDef, newmem);
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef) < 0)
goto cleanup;
}
} else {
......@@ -770,7 +771,8 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
persistentDef->mem.cur_balloon = newmem;
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef) < 0)
goto cleanup;
}
}
......@@ -915,7 +917,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
#undef LXC_SET_MEM_PARAMETER
if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
virDomainSaveConfig(cfg->configDir, vmdef) < 0)
virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0)
goto cleanup;
ret = 0;
......@@ -2025,7 +2027,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
rc = virDomainSaveConfig(cfg->configDir, vmdef);
rc = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (rc < 0)
goto cleanup;
......@@ -2727,7 +2729,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
}
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
ret = -1;
}
......@@ -5081,7 +5083,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -5203,7 +5205,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -5323,7 +5325,7 @@ static int lxcDomainDetachDeviceFlags(virDomainPtr dom,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......
......@@ -189,6 +189,7 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
VIR_WARN("Unable to save status on vm %s after block job",
vm->def->name);
if (persistDisk && virDomainSaveConfig(cfg->configDir,
driver->caps,
vm->newDef) < 0)
VIR_WARN("Unable to update persistent definition on vm %s "
"after block job", vm->def->name);
......
......@@ -2432,7 +2432,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (persistentDef->mem.cur_balloon > newmem)
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef);
goto endjob;
}
......@@ -2471,7 +2472,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
if (persistentDef) {
persistentDef->mem.cur_balloon = newmem;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef);
goto endjob;
}
}
......@@ -2560,7 +2562,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
goto endjob;
}
persistentDef->memballoon->period = period;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
......@@ -5103,7 +5105,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef) < 0)
goto endjob;
}
......@@ -5293,7 +5296,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
}
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
......@@ -5497,7 +5500,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
if (!(persistentDef->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
goto endjob;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
......@@ -5997,7 +6000,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
iothrid->cpumask = cpumask;
iothrid->autofill = false;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
......@@ -6300,7 +6303,8 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
persistentDef->iothreads--;
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps,
persistentDef) < 0)
goto endjob;
}
......@@ -7624,7 +7628,7 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
}
vm->persistent = 1;
if (virDomainSaveConfig(cfg->configDir,
if (virDomainSaveConfig(cfg->configDir, driver->caps,
vm->newDef ? vm->newDef : vm->def) < 0) {
if (oldDef) {
/* There is backup so this VM was defined before.
......@@ -8614,7 +8618,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -8740,7 +8744,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -8860,7 +8864,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
/* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
ret = virDomainSaveConfig(cfg->configDir, vmdef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (!ret) {
virDomainObjAssignDef(vm, vmdef, false, NULL);
vmdef = NULL;
......@@ -9418,7 +9422,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
}
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
ret = -1;
}
......@@ -9975,7 +9979,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
goto endjob;
if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
goto endjob;
ret = 0;
......@@ -10251,7 +10255,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
-1, mode, nodeset) < 0)
goto endjob;
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
goto endjob;
}
......@@ -10613,7 +10617,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
rc = virDomainSaveConfig(cfg->configDir, vmdef);
rc = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
if (rc < 0)
goto endjob;
......@@ -11410,7 +11414,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
}
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
goto endjob;
}
......@@ -13738,7 +13742,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
}
defdisk->src->format = snapdisk->src->format;
if (virDomainSaveConfig(cfg->configDir, vm->def) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0)
goto cleanup;
}
}
......@@ -14518,7 +14522,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
if (ret == 0 || !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) {
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0 ||
(persist && virDomainSaveConfig(cfg->configDir, vm->newDef) < 0))
(persist && virDomainSaveConfig(cfg->configDir, driver->caps,
vm->newDef) < 0))
ret = -1;
}
virObjectUnref(cfg);
......@@ -17811,7 +17816,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
info.write_iops_sec = oldinfo->write_iops_sec;
}
conf_disk->blkdeviotune = info;
ret = virDomainSaveConfig(cfg->configDir, persistentDef);
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
if (ret < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Write to config file failed"));
......@@ -20035,7 +20040,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
vm->def->name = new_dom_name;
new_dom_name = NULL;
if (virDomainSaveConfig(cfg->configDir, vm->def) < 0)
if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0)
goto rollback;
if (virFileExists(old_dom_cfg_file) &&
......
......@@ -5747,7 +5747,8 @@ qemuMigrationPersist(virQEMUDriverPtr driver,
if (!(vmdef = virDomainObjGetPersistentDef(caps, driver->xmlopt, vm)))
goto error;
if (virDomainSaveConfig(cfg->configDir, vmdef) < 0 && !ignoreSaveError)
if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0 &&
!ignoreSaveError)
goto error;
event = virDomainEventLifecycleNewFromObj(vm,
......
......@@ -3924,6 +3924,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
static int
qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
virCapsPtr caps,
virDomainObjPtr vm,
bool migrated)
{
......@@ -3963,7 +3964,7 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
generated = true;
if (vm->persistent &&
virDomainSaveConfig(cfg->configDir, vm->def) < 0)
virDomainSaveConfig(cfg->configDir, caps, vm->def) < 0)
goto cleanup;
}
......@@ -4437,7 +4438,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
* Fill them in prior to setting the domain def as transient. */
VIR_DEBUG("Generating paths");
if (qemuPrepareNVRAM(cfg, vm, migration) < 0)
if (qemuPrepareNVRAM(cfg, caps, vm, migration) < 0)
goto stop;
/* Do this upfront, so any part of the startup process can add
......
......@@ -2103,7 +2103,7 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
def = NULL;
vm->persistent = 1;
if (virDomainSaveConfig(driver->configDir,
if (virDomainSaveConfig(driver->configDir, driver->caps,
vm->newDef ? vm->newDef : vm->def) < 0) {
virDomainObjListRemove(driver->domains,
vm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册