[Spice-commits] 4 commits - CMakeLists.txt .gitmodules Makefile.am spice-common vdagent/file_xfer.cpp vdagent/file_xfer.h vdagent/vdagent.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 24 09:37:56 UTC 2020
.gitmodules | 5 +++++
CMakeLists.txt | 3 ++-
Makefile.am | 3 +++
spice-common | 1 +
vdagent/file_xfer.cpp | 25 ++++++++++++++-----------
vdagent/file_xfer.h | 7 ++++---
vdagent/vdagent.cpp | 27 ++++++++++++++++++---------
7 files changed, 47 insertions(+), 24 deletions(-)
New commits:
commit b4776f4291bb36c2814b3d2affe49af041fb133a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 18 20:29:02 2020 +0000
file_xfer: Return detailed error for no space
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 0322e03..51f7d34 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -113,6 +113,9 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
return;
}
if (free_bytes.QuadPart < file_size) {
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE;
+ status.not_enough_space.disk_free_space = free_bytes.QuadPart;
+ status_size = sizeof(status.common) + sizeof(status.not_enough_space);
vd_printf("insufficient disk space %" PRIu64, free_bytes.QuadPart);
return;
}
commit ab3353b5799d14431d08aa620a84cd1cc81ec56c
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 18 20:51:33 2020 +0000
vdagent: Return better error if locked
Use specific VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED error.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 36fc167..b1f7edf 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -1345,7 +1345,7 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
if (_session_is_locked) {
VDAgentFileXferStartMessage *s = (VDAgentFileXferStartMessage *)msg->data;
status.common.id = s->id;
- status.common.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED;
vd_printf("Fail to start file-xfer %u due: Locked session", status.common.id);
agent_prepare_filexfer_status(&status, &status_size,
_client_caps.data(), _client_caps.size());
commit a914784295b2ffed8ce002fab37fd158fdfba28d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 18 20:28:00 2020 +0000
vdagent: Allow to return detailed message for file transfer
Reuse AgentFileXferStatusMessageFull and agent_prepare_filexfer_status
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 016bd4e..0322e03 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -77,7 +77,7 @@ static bool get_download_directory(TCHAR file_path[MAX_PATH])
}
void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
- VDAgentFileXferStatusMessage* status)
+ AgentFileXferStatusMessageFull& status, size_t& status_size)
{
char* file_meta = (char*)start->data;
TCHAR file_path[MAX_PATH];
@@ -88,8 +88,8 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
AsUser as_user;
size_t wlen;
- status->id = start->id;
- status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
+ status.common.id = start->id;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
if (!g_key_get_string(file_meta, "vdagent-file-xfer", "name", file_name, sizeof(file_name)) ||
!g_key_get_uint64(file_meta, "vdagent-file-xfer", "size", &file_size)) {
vd_printf("file id %u meta parsing failed", start->id);
@@ -165,17 +165,17 @@ void FileXfer::handle_start(VDAgentFileXferStartMessage* start,
}
auto task = std::make_shared<FileXferTask>(handle, file_size, file_path);
_tasks[start->id] = task;
- status->result = VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA;
}
bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
- VDAgentFileXferStatusMessage* status)
+ AgentFileXferStatusMessageFull& status, size_t& status_size)
{
FileXferTasks::iterator iter;
DWORD written;
- status->id = data->id;
- status->result = VD_AGENT_FILE_XFER_STATUS_ERROR;
+ status.common.id = data->id;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
iter = _tasks.find(data->id);
if (iter == _tasks.end()) {
vd_printf("file id %u not found", data->id);
@@ -197,7 +197,7 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
}
vd_printf("%u completed", iter->first);
task->success();
- status->result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
fin:
_tasks.erase(iter);
@@ -252,17 +252,17 @@ void FileXfer::handle_status(VDAgentFileXferStatusMessage* status)
_tasks.erase(iter);
}
-bool FileXfer::dispatch(VDAgentMessage* msg, VDAgentFileXferStatusMessage* status)
+bool FileXfer::dispatch(VDAgentMessage* msg, AgentFileXferStatusMessageFull& status, size_t& status_size)
{
bool ret = false;
switch (msg->type) {
case VD_AGENT_FILE_XFER_START:
- handle_start((VDAgentFileXferStartMessage*)msg->data, status);
+ handle_start((VDAgentFileXferStartMessage*)msg->data, status, status_size);
ret = true;
break;
case VD_AGENT_FILE_XFER_DATA:
- ret = handle_data((VDAgentFileXferDataMessage*)msg->data, status);
+ ret = handle_data((VDAgentFileXferDataMessage*)msg->data, status, status_size);
break;
case VD_AGENT_FILE_XFER_STATUS:
handle_status((VDAgentFileXferStatusMessage*)msg->data);
diff --git a/vdagent/file_xfer.h b/vdagent/file_xfer.h
index b138019..3723b38 100644
--- a/vdagent/file_xfer.h
+++ b/vdagent/file_xfer.h
@@ -20,6 +20,7 @@
#include <map>
#include <memory>
+#include <common/agent.h>
#include "vdcommon.h"
struct FileXferTask {
@@ -46,12 +47,12 @@ typedef std::map<uint32_t, std::shared_ptr<FileXferTask> > FileXferTasks;
class FileXfer {
public:
~FileXfer();
- bool dispatch(VDAgentMessage* msg, VDAgentFileXferStatusMessage* status);
+ bool dispatch(VDAgentMessage* msg, AgentFileXferStatusMessageFull& status, size_t& status_size);
void reset();
private:
- void handle_start(VDAgentFileXferStartMessage* start, VDAgentFileXferStatusMessage* status);
- bool handle_data(VDAgentFileXferDataMessage* data, VDAgentFileXferStatusMessage* status);
+ void handle_start(VDAgentFileXferStartMessage* start, AgentFileXferStatusMessageFull& status, size_t& status_size);
+ bool handle_data(VDAgentFileXferDataMessage* data, AgentFileXferStatusMessageFull& status, size_t& status_size);
void handle_status(VDAgentFileXferStatusMessage* status);
bool g_key_get_string(char* data, const char* group, const char* key, char* value,
unsigned vsize);
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index df794b8..36fc167 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -846,6 +846,7 @@ bool VDAgent::send_announce_capabilities(bool request)
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG);
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_GUEST_LINEEND_CRLF);
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MAX_CLIPBOARD);
+ VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS);
vd_printf("Sending capabilities:");
for (uint32_t i = 0 ; i < caps_size; ++i) {
vd_printf("%X", caps->caps[i]);
@@ -1339,22 +1340,30 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
res = handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg->data, msg->size);
break;
case VD_AGENT_FILE_XFER_START: {
- VDAgentFileXferStatusMessage status;
+ AgentFileXferStatusMessageFull status;
+ size_t status_size = sizeof(status.common);
if (_session_is_locked) {
VDAgentFileXferStartMessage *s = (VDAgentFileXferStartMessage *)msg->data;
- status.id = s->id;
- status.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
- vd_printf("Fail to start file-xfer %u due: Locked session", status.id);
- write_message(VD_AGENT_FILE_XFER_STATUS, sizeof(status), &status);
- } else if (_file_xfer.dispatch(msg, &status)) {
- write_message(VD_AGENT_FILE_XFER_STATUS, sizeof(status), &status);
+ status.common.id = s->id;
+ status.common.result = VD_AGENT_FILE_XFER_STATUS_ERROR;
+ vd_printf("Fail to start file-xfer %u due: Locked session", status.common.id);
+ agent_prepare_filexfer_status(&status, &status_size,
+ _client_caps.data(), _client_caps.size());
+ write_message(VD_AGENT_FILE_XFER_STATUS, status_size, &status);
+ } else if (_file_xfer.dispatch(msg, status, status_size)) {
+ agent_prepare_filexfer_status(&status, &status_size,
+ _client_caps.data(), _client_caps.size());
+ write_message(VD_AGENT_FILE_XFER_STATUS, status_size, &status);
}
break;
}
case VD_AGENT_FILE_XFER_STATUS:
case VD_AGENT_FILE_XFER_DATA: {
- VDAgentFileXferStatusMessage status;
- if (_file_xfer.dispatch(msg, &status)) {
+ AgentFileXferStatusMessageFull status;
+ size_t status_size = sizeof(status.common);
+ if (_file_xfer.dispatch(msg, status, status_size)) {
+ agent_prepare_filexfer_status(&status, &status_size,
+ _client_caps.data(), _client_caps.size());
write_message(VD_AGENT_FILE_XFER_STATUS, sizeof(status), &status);
}
break;
commit 3cad1e7570255a90aa07a1fea14fd0d112aec4c2
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Mar 18 20:23:29 2020 +0000
Compile in agent utilities from spice-common
Allows these utilities to be used in the code.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/.gitmodules b/.gitmodules
index f946a4d..9b61820 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,8 @@
[submodule "spice-protocol"]
path = spice-protocol
url = git://git.freedesktop.org/git/spice/spice-protocol.git
+
+[submodule "spice-common"]
+ path = spice-common
+ url = git://git.freedesktop.org/git/spice/spice-common.git
+ ignore = untracked
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 039079b..2a8b2b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,7 +76,7 @@ else(MSVC)
set(COMMSUPPW_LIBRARY)
endif(MSVC)
-include_directories(common ${CMAKE_BINARY_DIR} spice-protocol ${PNG_INCLUDE_DIR})
+include_directories(common ${CMAKE_BINARY_DIR} spice-protocol spice-common ${PNG_INCLUDE_DIR})
add_definitions(-DUNICODE -D_UNICODE -DOLDMSVCRT -DWINVER=0x0601)
add_executable(vdagent WIN32
@@ -93,6 +93,7 @@ add_executable(vdagent WIN32
vdagent/file_xfer.cpp
vdagent/file_xfer.h
vdagent/vdagent.cpp
+ spice-common/common/agent.c
vdagent/as_user.cpp
vdagent/as_user.h
vdagent/image.cpp
diff --git a/Makefile.am b/Makefile.am
index 8da212e..6e464c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS = \
-DWINVER=0x0601 \
-I$(top_srcdir)/common \
-I$(top_srcdir)/spice-protocol \
+ -I$(top_srcdir)/spice-common \
$(NULL)
AM_LDFLAGS = -static
@@ -26,6 +27,8 @@ vdagent_SOURCES = \
common/vdcommon.h \
common/vdlog.cpp \
common/vdlog.h \
+ spice-common/common/agent.c \
+ spice-common/common/agent.h \
vdagent/display_configuration.cpp \
vdagent/display_configuration.h \
vdagent/desktop_layout.cpp \
diff --git a/spice-common b/spice-common
new file mode 160000
index 0000000..05c0c26
--- /dev/null
+++ b/spice-common
@@ -0,0 +1 @@
+Subproject commit 05c0c26839e88e6d0cc5452f49c40e38543c8f97
More information about the Spice-commits
mailing list