[PATCH spice-vdagent v2] file-xfer: Send more detailed error messages

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

 



Send VD_AGENT_FILE_XFER_STATUS_AGENT_NOT_CONNECTED,
VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED or
VD_AGENT_FILE_XFER_STATUS_DISABLED instead of general error, when the
given error occurs.

send_file_xfer_status() ensures, these errors are sent only to clients with
VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS capability.
---
 src/vdagent/file-xfers.c | 4 ++--
 src/vdagent/file-xfers.h | 2 +-
 src/vdagent/vdagent.c    | 6 +++---
 src/vdagentd/vdagentd.c  | 8 ++++++--
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/vdagent/file-xfers.c b/src/vdagent/file-xfers.c
index 51fccd7..344db6b 100644
--- a/src/vdagent/file-xfers.c
+++ b/src/vdagent/file-xfers.c
@@ -356,10 +356,10 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
     }
 }
 
-void vdagent_file_xfers_error(struct udscs_connection *vdagentd, uint32_t msg_id)
+void vdagent_file_xfers_error_disabled(struct udscs_connection *vdagentd, uint32_t msg_id)
 {
     g_return_if_fail(vdagentd != NULL);
 
     udscs_write(vdagentd, VDAGENTD_FILE_XFER_STATUS,
-                msg_id, VD_AGENT_FILE_XFER_STATUS_ERROR, NULL, 0);
+                msg_id, VD_AGENT_FILE_XFER_STATUS_DISABLED, NULL, 0);
 }
diff --git a/src/vdagent/file-xfers.h b/src/vdagent/file-xfers.h
index 28a71fd..3e2ed1d 100644
--- a/src/vdagent/file-xfers.h
+++ b/src/vdagent/file-xfers.h
@@ -37,7 +37,7 @@ void vdagent_file_xfers_status(struct vdagent_file_xfers *xfers,
     VDAgentFileXferStatusMessage *msg);
 void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
     VDAgentFileXferDataMessage *msg);
-void vdagent_file_xfers_error(struct udscs_connection *vdagentd,
+void vdagent_file_xfers_error_disabled(struct udscs_connection *vdagentd,
     uint32_t msg_id);
 
 #endif
diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index 6f025e8..e034234 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -89,7 +89,7 @@ static void daemon_read_complete(struct udscs_connection **connp,
             vdagent_file_xfers_start(vdagent_file_xfers,
                                      (VDAgentFileXferStartMessage *)data);
         } else {
-            vdagent_file_xfers_error(*connp,
+            vdagent_file_xfers_error_disabled(*connp,
                                      ((VDAgentFileXferStartMessage *)data)->id);
         }
         break;
@@ -98,7 +98,7 @@ static void daemon_read_complete(struct udscs_connection **connp,
             vdagent_file_xfers_status(vdagent_file_xfers,
                                       (VDAgentFileXferStatusMessage *)data);
         } else {
-            vdagent_file_xfers_error(*connp,
+            vdagent_file_xfers_error_disabled(*connp,
                                      ((VDAgentFileXferStatusMessage *)data)->id);
         }
         break;
@@ -125,7 +125,7 @@ static void daemon_read_complete(struct udscs_connection **connp,
             vdagent_file_xfers_data(vdagent_file_xfers,
                                     (VDAgentFileXferDataMessage *)data);
         } else {
-            vdagent_file_xfers_error(*connp,
+            vdagent_file_xfers_error_disabled(*connp,
                                      ((VDAgentFileXferDataMessage *)data)->id);
         }
         break;
diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
index 73b892f..a48f535 100644
--- a/src/vdagentd/vdagentd.c
+++ b/src/vdagentd/vdagentd.c
@@ -349,14 +349,14 @@ static void do_client_file_xfer(struct vdagent_virtio_port *vport,
             send_file_xfer_status(vport,
                "Could not find an agent connection belonging to the "
                "active session, cancelling file-xfer",
-               s->id, VD_AGENT_FILE_XFER_STATUS_CANCELLED, NULL, 0);
+               s->id, VD_AGENT_FILE_XFER_STATUS_AGENT_NOT_CONNECTED, NULL, 0);
             return;
         } else if (session_info_session_is_locked(session_info)) {
             syslog(LOG_DEBUG, "Session is locked, skipping file-xfer-start");
             send_file_xfer_status(vport,
                "User's session is locked and cannot start file transfer. "
                "Cancelling file-xfer",
-               s->id, VD_AGENT_FILE_XFER_STATUS_ERROR, NULL, 0);
+               s->id, VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED, NULL, 0);
             return;
         }
         udscs_write(active_session_conn, VDAGENTD_FILE_XFER_START, 0, 0,
@@ -927,6 +927,10 @@ static void agent_read_complete(struct udscs_connection **connp,
                 send_file_xfer_status(virtio_port, "Not enough free space. Cancelling file-xfer",
                                       header->arg1, header->arg2, data, sizeof(uint64_t));
                 break;
+            case VD_AGENT_FILE_XFER_STATUS_DISABLED:
+                send_file_xfer_status(virtio_port, "File-xfer is disabled, cancelling",
+                                      header->arg1, header->arg2, NULL, 0);
+                break;
             default:
                 send_file_xfer_status(virtio_port, NULL, header->arg1, header->arg2, NULL, 0);
         }
-- 
2.13.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]