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: Joao Martins <joao.m.martins(a)oracle.com>
---
src/bhyve/bhyve_driver.c | 2 +-
src/conf/domain_conf.c | 5 +++--
src/conf/domain_conf.h | 1 +
src/libxl/libxl_driver.c | 15 ++++++++-------
src/lxc/lxc_driver.c | 20 +++++++++++---------
src/qemu/qemu_blockjob.c | 1 +
src/qemu/qemu_driver.c | 47 ++++++++++++++++++++++++++---------------------
src/qemu/qemu_migration.c | 3 ++-
src/qemu/qemu_process.c | 5 +++--
src/uml/uml_driver.c | 2 +-
10 files changed, 57 insertions(+), 44 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index c23c310..337a29e 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4ecf700..6b70543 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -22694,12 +22694,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))
@@ -23883,7 +23884,7 @@ virDomainObjSetMetadata(virDomainObjPtr vm,
uri) < 0)
return -1;
- if (virDomainSaveConfig(configDir, persistentDef) < 0)
+ if (virDomainSaveConfig(configDir, caps, persistentDef) < 0)
return -1;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6ae2e1b..a8d0225 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2907,6 +2907,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,
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index dfaf3a0..d2114ca 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -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;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 7be92c7..58c9bb4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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;
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 1d5b7ce..f14e70b 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -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);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 37e348e..26f2584 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2429,7 +2429,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;
}
@@ -2468,7 +2469,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;
}
}
@@ -2557,7 +2559,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;
}
@@ -5080,7 +5082,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;
}
@@ -5270,7 +5273,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
}
- ret = virDomainSaveConfig(cfg->configDir, persistentDef);
+ ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
@@ -5474,7 +5477,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;
}
@@ -5974,7 +5977,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
iothrid->cpumask = cpumask;
iothrid->autofill = false;
- ret = virDomainSaveConfig(cfg->configDir, persistentDef);
+ ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
}
@@ -6277,7 +6280,8 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
persistentDef->iothreads--;
}
- if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
+ if (virDomainSaveConfig(cfg->configDir, driver->caps,
+ persistentDef) < 0)
goto endjob;
}
@@ -7601,7 +7605,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.
@@ -8591,7 +8595,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;
@@ -8717,7 +8721,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;
@@ -8837,7 +8841,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;
@@ -9395,7 +9399,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
}
}
- if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
+ if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) <
0)
ret = -1;
}
@@ -9952,7 +9956,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;
@@ -10228,7 +10232,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;
}
@@ -10590,7 +10594,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;
@@ -11387,7 +11391,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
}
}
- if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
+ if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) <
0)
goto endjob;
}
@@ -13715,7 +13719,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;
}
}
@@ -14495,7 +14499,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);
@@ -17788,7 +17793,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"));
@@ -20069,7 +20074,7 @@ static int qemuDomainRename(virDomainPtr dom,
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) &&
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 51e7125..2f5b368 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ee94d3f..0b34375 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3996,6 +3996,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
static int
qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
+ virCapsPtr caps,
virDomainObjPtr vm,
bool migrated)
{
@@ -4035,7 +4036,7 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
generated = true;
if (vm->persistent &&
- virDomainSaveConfig(cfg->configDir, vm->def) < 0)
+ virDomainSaveConfig(cfg->configDir, caps, vm->def) < 0)
goto cleanup;
}
@@ -4509,7 +4510,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
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4469426..3cfa36f 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -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);
--
2.1.4