After set network interface's bandwidth for running domain, save the change
into live xml is needed to survive restarting the libvirtd, same story with
bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob
in qemuDomainSetInterfaceParameters
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/qemu/qemu_driver.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 95244b4..dc3d0e4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10133,16 +10133,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
- goto cleanup;
+ goto endjob;
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
net = virDomainNetFind(vm->def, device);
if (!net) {
virReportError(VIR_ERR_INVALID_ARG,
_("Can't find device %s"), device);
- goto cleanup;
+ goto endjob;
}
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
@@ -10150,14 +10153,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (!persistentNet) {
virReportError(VIR_ERR_INVALID_ARG,
_("Can't find device %s"), device);
- goto cleanup;
+ goto endjob;
}
}
if ((VIR_ALLOC(bandwidth) < 0) ||
(VIR_ALLOC(bandwidth->in) < 0) ||
(VIR_ALLOC(bandwidth->out) < 0))
- goto cleanup;
+ goto endjob;
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
@@ -10191,7 +10194,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (VIR_ALLOC(newBandwidth) < 0)
- goto cleanup;
+ goto endjob;
/* virNetDevBandwidthSet() will clear any previous value of
* bandwidth parameters, so merge with old bandwidth parameters
@@ -10199,7 +10202,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (bandwidth->in ||
(!inboundSpecified && net->bandwidth &&
net->bandwidth->in)) {
if (VIR_ALLOC(newBandwidth->in) < 0)
- goto cleanup;
+ goto endjob;
memcpy(newBandwidth->in,
bandwidth->in ? bandwidth->in : net->bandwidth->in,
@@ -10208,7 +10211,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (bandwidth->out ||
(!outboundSpecified && net->bandwidth &&
net->bandwidth->out)) {
if (VIR_ALLOC(newBandwidth->out) < 0)
- goto cleanup;
+ goto endjob;
memcpy(newBandwidth->out,
bandwidth->out ? bandwidth->out : net->bandwidth->out,
@@ -10216,7 +10219,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
}
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0)
- goto cleanup;
+ goto endjob;
virNetDevBandwidthFree(net->bandwidth);
if (newBandwidth->in || newBandwidth->out) {
@@ -10225,6 +10228,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else {
net->bandwidth = NULL;
}
+ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+ goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (!persistentNet->bandwidth) {
@@ -10248,10 +10253,15 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
}
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
- goto cleanup;
+ goto endjob;
}
ret = 0;
+
+ endjob:
+ if (!qemuDomainObjEndJob(driver, vm))
+ vm = NULL;
+
cleanup:
virNetDevBandwidthFree(bandwidth);
virNetDevBandwidthFree(newBandwidth);
--
1.9.3