]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: don't fail update netdev on bridge detach failure
authorLaine Stump <laine@laine.org>
Fri, 14 Dec 2012 00:09:51 +0000 (19:09 -0500)
committerLaine Stump <laine@laine.org>
Fri, 14 Dec 2012 12:14:10 +0000 (07:14 -0500)
When a network device's bridge connection is changed by
virDomainUpdateDevice, libvirt first removes the netdev's tap from its
old bridge, then adds it to the new bridge. Sometimes, due to a
network being destroyed while a guest device is still attached, the
tap may already be "removed" from the old bridge (or the old bridge
may not even exist any more); the existing code was needlessly failing
the update when this happened, making it impossible to recover from
the situation without completely detaching (i.e. removing) the netdev
from the guest and re-attaching.

Instead of failing the entire operation when removal of the tap from
the old bridge fails, this patch changes qemuDomainChangeNetBridge to
just log a warning and continue, allowing a reasonable recover from
the situation.

(you'll appreciate this change if you ever accidentally destroy a
network while your guests are still using it).

src/qemu/qemu_hotplug.c

index 3dfdb65ad9e5e81c0312010225bb150d85d5becf..e9a5e3570c1843326e14e91e9ba7d27097fd7d10 100644 (file)
@@ -1306,8 +1306,14 @@ qemuDomainChangeNetBridge(virConnectPtr conn,
     if (oldbridge) {
         ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname);
         virDomainAuditNet(vm, olddev, NULL, "detach", ret == 0);
-        if (ret < 0)
-            goto cleanup;
+        if (ret < 0) {
+            /* warn but continue - possibly the old network
+             * had been destroyed and reconstructed, leaving the
+             * tap device orphaned.
+             */
+            VIR_WARN("Unable to detach device %s from bridge %s",
+                     olddev->ifname, oldbridge);
+        }
     }
 
     ret = virNetDevBridgeAddPort(newbridge, olddev->ifname);