Blame SOURCES/0009-channel-main-Handle-some-detailed-error-for-VD_AGENT.patch

84be6c
From 769465494c5e3e4299a2dfdf6e0c835be4e04ab7 Mon Sep 17 00:00:00 2001
84be6c
From: Frediano Ziglio <fziglio@redhat.com>
84be6c
Date: Thu, 19 Mar 2020 06:12:34 +0000
84be6c
Subject: [PATCH 9/9] channel-main: Handle some detailed error for
84be6c
 VD_AGENT_FILE_XFER_STATUS_ERROR
84be6c
84be6c
Detect presence of detail on VD_AGENT_FILE_XFER_STATUS_ERROR and
84be6c
if the error is supported give more detailed information, otherwise
84be6c
fallback to the old generic error.
84be6c
84be6c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
84be6c
Acked-by: Victor Toso <victortoso@redhat.com>
84be6c
(cherry picked from commit d79b05dcff83792c8415cafbb288d614de9d3101)
84be6c
---
84be6c
 src/channel-main.c | 22 +++++++++++++++++++---
84be6c
 1 file changed, 19 insertions(+), 3 deletions(-)
84be6c
84be6c
diff --git a/src/channel-main.c b/src/channel-main.c
84be6c
index c4fe02b..d845fda 100644
84be6c
--- a/src/channel-main.c
84be6c
+++ b/src/channel-main.c
84be6c
@@ -1913,10 +1913,26 @@ static void main_agent_handle_xfer_status(SpiceMainChannel *channel,
84be6c
         error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
84be6c
                                     _("The spice agent cancelled the file transfer"));
84be6c
         break;
84be6c
-    case VD_AGENT_FILE_XFER_STATUS_ERROR:
84be6c
-        error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
84be6c
-                                    _("The spice agent reported an error during the file transfer"));
84be6c
+    case VD_AGENT_FILE_XFER_STATUS_ERROR: {
84be6c
+        const VDAgentFileXferStatusError *err = (VDAgentFileXferStatusError *) msg->data;
84be6c
+        if (test_agent_cap(channel, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS) &&
84be6c
+            msg_hdr->size >= sizeof(*msg) + sizeof(*err) &&
84be6c
+            err->error_type == VD_AGENT_FILE_XFER_STATUS_ERROR_GLIB_IO) {
84be6c
+
84be6c
+            switch (err->error_code) {
84be6c
+            case G_IO_ERROR_INVALID_FILENAME:
84be6c
+                error = g_error_new_literal(G_IO_ERROR, err->error_code,
84be6c
+                                            _("Invalid filename of transferred file"));
84be6c
+                break;
84be6c
+            }
84be6c
+        }
84be6c
+        if (error == NULL) {
84be6c
+            error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
84be6c
+                                        _("The spice agent reported an error "
84be6c
+                                          "during the file transfer"));
84be6c
+        }
84be6c
         break;
84be6c
+    }
84be6c
     case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE: {
84be6c
         const VDAgentFileXferStatusNotEnoughSpace *err =
84be6c
             (VDAgentFileXferStatusNotEnoughSpace*) msg->data;
84be6c
-- 
84be6c
2.26.2
84be6c