c8c376
From f87f0fc731dcb28cfcbe65bb7a69628f431030aa Mon Sep 17 00:00:00 2001
c8c376
Message-Id: <f87f0fc731dcb28cfcbe65bb7a69628f431030aa@dist-git>
c8c376
From: Michal Privoznik <mprivozn@redhat.com>
c8c376
Date: Thu, 15 Dec 2016 18:17:45 +0100
c8c376
Subject: [PATCH] qemuDomainAttachNetDevice: Don't overwrite error on rollback
c8c376
c8c376
RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1386976
c8c376
RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186
c8c376
c8c376
If there is an error hotpluging a net device (for whatever
c8c376
reason) a rollback operation is performed. However, whilst doing
c8c376
so various helper functions that are called report errors on
c8c376
their own. This results in the original error to be overwritten
c8c376
and thus misleading the user.
c8c376
c8c376
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c8c376
(cherry picked from commit 0e82fa4c345acb7ad52e0da0e54f7375eda57657)
c8c376
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c8c376
---
c8c376
 src/qemu/qemu_hotplug.c | 4 ++++
c8c376
 1 file changed, 4 insertions(+)
c8c376
c8c376
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c8c376
index 8acbf370b..573cb8c93 100644
c8c376
--- a/src/qemu/qemu_hotplug.c
c8c376
+++ b/src/qemu/qemu_hotplug.c
c8c376
@@ -885,6 +885,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
c8c376
                           virDomainNetDefPtr net)
c8c376
 {
c8c376
     qemuDomainObjPrivatePtr priv = vm->privateData;
c8c376
+    virErrorPtr originalError = NULL;
c8c376
     char **tapfdName = NULL;
c8c376
     int *tapfd = NULL;
c8c376
     size_t tapfdSize = 0;
c8c376
@@ -1266,6 +1267,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
c8c376
     if (!virDomainObjIsActive(vm))
c8c376
         goto cleanup;
c8c376
 
c8c376
+    originalError = virSaveLastError();
c8c376
     if (vlan < 0) {
c8c376
         if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
c8c376
             char *netdev_name;
c8c376
@@ -1296,6 +1298,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
c8c376
         ignore_value(qemuDomainObjExitMonitor(driver, vm));
c8c376
         VIR_FREE(hostnet_name);
c8c376
     }
c8c376
+    virSetError(originalError);
c8c376
+    virFreeError(originalError);
c8c376
     goto cleanup;
c8c376
 }
c8c376
 
c8c376
-- 
c8c376
2.11.0
c8c376