]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Restore old bandwidth rules when setting new fails
authorLuyao Huang <lhuang@redhat.com>
Wed, 31 Dec 2014 01:34:39 +0000 (09:34 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 6 Jan 2015 12:27:43 +0000 (13:27 +0100)
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 <lhuang@redhat.com>
src/qemu/qemu_driver.c

index 1596d2bc2586b550d6de1ebbd87b977ec3b59f58..cdf4173809fffa8e0d57ce74619468aae0dd09be 100644 (file)
@@ -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) {