]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: save/restore original error when recovering from failed bridge attach
authorLaine Stump <laine@redhat.com>
Thu, 13 Feb 2020 16:57:43 +0000 (11:57 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 21 Feb 2020 04:05:24 +0000 (23:05 -0500)
Not only was the original error code destroyed in the case of
encountering an error during recovery from a failed attach to the
bridge (and then *that* error was destroyed by logging a *second*
error about the failure to recover - virNetDevBridgeAddPort() already
logs an error, so the one about failing to recover was redundant), but
if the recovery was successful, the function would then return success
to the caller even though it had failed.

Fixes: 2711ac87160d7ac7d550c57f4339e6c6749942fa
(overwritten errors were introduced along with this functionality)
Fixes: 6bde0a1a37424c84492658223ff845b1ebb0e25c
(the wrong return value was introduced by a refactor)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c

index c84088996835f1afa7d01768156c914c35f9a0f6..6395826c69ae6ace1615e687aac3b436dc443bfd 100644 (file)
@@ -3352,14 +3352,13 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
     ret = virNetDevBridgeAddPort(newbridge, olddev->ifname);
     virDomainAuditNet(vm, NULL, newdev, "attach", ret == 0);
     if (ret < 0) {
+        virErrorPtr err;
+
+        virErrorPreserveLast(&err);
         ret = virNetDevBridgeAddPort(oldbridge, olddev->ifname);
         virDomainAuditNet(vm, NULL, olddev, "attach", ret == 0);
-        if (ret < 0) {
-            virReportError(VIR_ERR_OPERATION_FAILED,
-                           _("unable to recover former state by adding port "
-                             "to bridge %s"), oldbridge);
-        }
-        return ret;
+        virErrorRestore(&err);
+        return -1;
     }
     /* caller will replace entire olddev with newdev in domain nets list */
     return 0;