]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
bridge: don't crash on bandwidth unplug with no bandwidth
authorJán Tomko <jtomko@redhat.com>
Fri, 21 Jun 2013 17:20:31 +0000 (19:20 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 27 Jun 2013 10:11:42 +0000 (12:11 +0200)
If networkUnplugBandwidth is called on a network which has
no bandwidth defined, print a warning instead of crashing.

This can happen when destroying a domain with bandwidth if
bandwidth was removed from the network after the domain was
started.

https://bugzilla.redhat.com/show_bug.cgi?id=975359

src/network/bridge_driver.c

index 2cf49bbcef9e7078ebc34155b974534b41948776..fb1741faead4aa94efc02f0d68f4a4b58d2ec7dd 100644 (file)
@@ -4871,6 +4871,11 @@ networkUnplugBandwidth(virNetworkObjPtr net,
 
     if (iface->data.network.actual &&
         iface->data.network.actual->class_id) {
+        if (!net->def->bandwidth || !net->def->bandwidth->in) {
+            VIR_WARN("Network %s has no bandwidth but unplug requested",
+                     net->def->name);
+            goto cleanup;
+        }
         /* we must remove class from bridge */
         new_rate = net->def->bandwidth->in->average;