From 565d049fd1a4f3264a12001467a0bbf3b87a6421 Mon Sep 17 00:00:00 2001 From: Luyao Huang Date: Wed, 31 Dec 2014 09:34:39 +0800 Subject: [PATCH] qemu: Restore old bandwidth rules when setting new fails https://bugzilla.redhat.com/show_bug.cgi?id=1177723 When setting new bandwidth limits via virDomainSetInterfaceParameters, the old ones are cleared first. However, if setting the new ones fails, the old are already gone and interface is left in inconsistent state. Therefore, right before failing we ought to try to restore the old bandwidth. Signed-off-by: Luyao Huang --- src/qemu/qemu_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1596d2bc25..cdf4173809 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10510,8 +10510,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, sizeof(*newBandwidth->out)); } - if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0) + if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0) { + ignore_value(virNetDevBandwidthSet(net->ifname, + net->bandwidth, + false)); goto endjob; + } virNetDevBandwidthFree(net->bandwidth); if (newBandwidth->in || newBandwidth->out) { -- GitLab