[PATCH 05/10] virsh: fix console stream error reporting

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

 



This patch subscribes the console stream event callback to handle errors
(and stream abortion) from the daemon. The functionality was (partly)
implemented in the callback, but the error events were not registered.
---
 tools/console.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/tools/console.c b/tools/console.c
index 0f85bc7..3913c42 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -109,6 +109,12 @@ virConsoleEventOnStream(virStreamPtr st,
 {
     virConsolePtr con = opaque;

+    if (events & VIR_STREAM_EVENT_ERROR ||
+        events & VIR_STREAM_EVENT_HANGUP) {
+        virConsoleShutdown(con);
+        return;
+    }
+
     if (events & VIR_STREAM_EVENT_READABLE) {
         size_t avail = con->streamToTerminal.length -
             con->streamToTerminal.offset;
@@ -169,12 +175,10 @@ virConsoleEventOnStream(virStreamPtr st,
     }
     if (!con->terminalToStream.offset)
         virStreamEventUpdateCallback(con->st,
-                                     VIR_STREAM_EVENT_READABLE);
+                                     ( VIR_STREAM_EVENT_READABLE |
+                                       VIR_STREAM_EVENT_HANGUP |
+                                       VIR_STREAM_EVENT_ERROR ));

-    if (events & VIR_STREAM_EVENT_ERROR ||
-        events & VIR_STREAM_EVENT_HANGUP) {
-        virConsoleShutdown(con);
-    }
 }

 static void
@@ -346,7 +350,9 @@ int vshRunConsole(virDomainPtr dom, const char *dev_name)
                                          NULL);

     virStreamEventAddCallback(con->st,
-                              VIR_STREAM_EVENT_READABLE,
+                              (VIR_STREAM_EVENT_READABLE |
+                               VIR_STREAM_EVENT_HANGUP |
+                               VIR_STREAM_EVENT_ERROR),
                               virConsoleEventOnStream,
                               con,
                               NULL);
@@ -356,7 +362,8 @@ int vshRunConsole(virDomainPtr dom, const char *dev_name)
             break;
     }

-    ret = 0;
+    if (!virGetLastError())
+        ret = 0;

  cleanup:

-- 
1.7.3.4

--
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]