[PATCH 14/17] virt-login-shell: avoid loosing error during cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The virDomainFree / virConnectClose methods will reset the
last error handle, so we must save the error during cleanup

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/virt-login-shell.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
index ed89ecf..3f2e3d0 100644
--- a/tools/virt-login-shell.c
+++ b/tools/virt-login-shell.c
@@ -219,6 +219,7 @@ main(int argc, char **argv)
     size_t i;
     const char *cmdstr = NULL;
     char *tmp;
+    virErrorPtr saved_err = NULL;
 
     struct option opt[] = {
         {"help", no_argument, NULL, 'h'},
@@ -399,6 +400,8 @@ main(int argc, char **argv)
     /* At this point, the parent is now waiting for the child to exit,
      * but as that may take a long time, we release resources now.  */
  cleanup:
+    saved_err = virSaveLastError();
+
     if (nfdlist > 0)
         for (i = 0; i < nfdlist; i++)
             VIR_FORCE_CLOSE(fdlist[i]);
@@ -419,7 +422,9 @@ main(int argc, char **argv)
     if (virProcessWait(cpid, &status, true) == 0)
         virProcessExitWithStatus(status);
 
-    if (virGetLastError())
+    if (saved_err) {
+        virSetError(saved_err);
         virDispatchError(NULL);
+    }
     return ret;
 }
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]