[Spice-devel] [PATCH vdagent-win 1/2] cleanup dispatch_message()
--- vdagent/vdagent.cpp | 23 +++ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 307b7da..af99961 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -1206,48 +1206,47 @@ bool VDAgent::init_vio_serial() void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port) { -VDAgent* a = _singleton; bool res = true; switch (msg-type) { case VD_AGENT_MOUSE_STATE: -res = a-handle_mouse_event((VDAgentMouseState*)msg-data); +res = handle_mouse_event((VDAgentMouseState*)msg-data); break; case VD_AGENT_MONITORS_CONFIG: -res = a-handle_mon_config((VDAgentMonitorsConfig*)msg-data, port); +res = handle_mon_config((VDAgentMonitorsConfig*)msg-data, port); break; case VD_AGENT_CLIPBOARD: -a-handle_clipboard((VDAgentClipboard*)msg-data, msg-size - sizeof(VDAgentClipboard)); +handle_clipboard((VDAgentClipboard*)msg-data, msg-size - sizeof(VDAgentClipboard)); break; case VD_AGENT_CLIPBOARD_GRAB: -a-handle_clipboard_grab((VDAgentClipboardGrab*)msg-data, msg-size); +handle_clipboard_grab((VDAgentClipboardGrab*)msg-data, msg-size); break; case VD_AGENT_CLIPBOARD_REQUEST: -res = a-handle_clipboard_request((VDAgentClipboardRequest*)msg-data); +res = handle_clipboard_request((VDAgentClipboardRequest*)msg-data); if (!res) { VDAgentClipboard clipboard = {VD_AGENT_CLIPBOARD_NONE}; -res = a-write_message(VD_AGENT_CLIPBOARD, sizeof(clipboard), clipboard); +res = write_message(VD_AGENT_CLIPBOARD, sizeof(clipboard), clipboard); } break; case VD_AGENT_CLIPBOARD_RELEASE: -a-handle_clipboard_release(); +handle_clipboard_release(); break; case VD_AGENT_DISPLAY_CONFIG: -res = a-handle_display_config((VDAgentDisplayConfig*)msg-data, port); +res = handle_display_config((VDAgentDisplayConfig*)msg-data, port); break; case VD_AGENT_ANNOUNCE_CAPABILITIES: -res = a-handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg-data, msg-size); +res = handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg-data, msg-size); break; case VD_AGENT_CLIENT_DISCONNECTED: vd_printf(Client disconnected, agent to be restarted); -a-set_control_event(CONTROL_STOP); +set_control_event(CONTROL_STOP); break; default: vd_printf(Unsupported message type %u size %u, msg-type, msg-size); } if (!res) { vd_printf(handling message type %u failed: %lu, msg-type, GetLastError()); -a-_running = false; +_running = false; } } -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win] vdagent: advertise CRLF line-ending
rhbz#872252 --- vdagent/vdagent.cpp |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index a061973..307b7da 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -796,6 +796,7 @@ bool VDAgent::send_announce_capabilities(bool request) VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_DISPLAY_CONFIG); VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND); 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_printf(Sending capabilities:); for (uint32_t i = 0 ; i caps_size; ++i) { vd_printf(%X, caps-caps[i]); -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win PATCH 2/2] vdagent: drop clipboard received after timeout
rhbz #951618 --- vdagent/vdagent.cpp | 13 ++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 1fad0e6..3c0f829 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -979,9 +979,12 @@ void VDAgent::on_clipboard_request(UINT format) event_dispatcher(VD_CLIPBOARD_TIMEOUT_MS, 0); } -cleanup_in_msg(); if (_clipboard_tick) { vd_printf(Clipboard wait timeout); +_clipboard_tick = 0; +} else { +// reset incoming message state only upon completion (even after timeout) +cleanup_in_msg(); } } @@ -1303,11 +1306,15 @@ void VDAgent::handle_chunk(VDIChunk* chunk) memcpy((uint8_t*)_in_msg + _in_msg_pos, chunk-data, chunk-hdr.size); _in_msg_pos += chunk-hdr.size; // update clipboard tick on each clipboard chunk for timeout setting -if (_in_msg-type == VD_AGENT_CLIPBOARD) { +if (_in_msg-type == VD_AGENT_CLIPBOARD _clipboard_tick) { _clipboard_tick = GetTickCount(); } if (_in_msg_pos == sizeof(VDAgentMessage) + _in_msg-size) { -dispatch_message(_in_msg, 0); +if (_in_msg-type == VD_AGENT_CLIPBOARD !_clipboard_tick) { +vd_printf(Clipboard received but dropped due to timeout); +} else { +dispatch_message(_in_msg, 0); +} cleanup_in_msg(); } } -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win PATCH 1/2] vdagent: add support for VD_AGENT_CLIENT_DISCONNECTED
vdagent is stopped, so a new instance is to be launched by vdservice. imho, this seems simpler than cleaning agent in/out msg state and reseting the vio-serial device to cleanup pending msgs. rhbz #956133 --- vdagent/vdagent.cpp |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 118cafd..1fad0e6 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -1226,6 +1226,10 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port) case VD_AGENT_ANNOUNCE_CAPABILITIES: res = a-handle_announce_capabilities((VDAgentAnnounceCapabilities*)msg-data, msg-size); break; +case VD_AGENT_CLIENT_DISCONNECTED: +vd_printf(Client disconnected, agent to be restarted); +a-set_control_event(CONTROL_STOP); +break; default: vd_printf(Unsupported message type %u size %u, msg-type, msg-size); } -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win PATCH] vdagent: support sparse monitors config
rhbz #953973 --- vdagent/vdagent.cpp |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index dde967c..118cafd 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -622,6 +622,11 @@ bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port VDAgentMonConfig* mon = mon_config-monitors[i]; vd_printf(%d. %u*%u*%u (%d,%d) %u, i, mon-width, mon-height, mon-depth, mon-x, mon-y, !!(mon_config-flags VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS)); +if (mon-height == 0 mon-depth == 0) { +vd_printf(%d. detaching, i); +mode-set_attached(false); +continue; +} mode-set_res(mon-width, mon-height, mon-depth); if (mon_config-flags VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS) { mode-set_pos(mon-x, mon-y); @@ -782,6 +787,7 @@ bool VDAgent::send_announce_capabilities(bool request) VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_REPLY); VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_DISPLAY_CONFIG); VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND); +VD_AGENT_SET_CAPABILITY(caps-caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG); vd_printf(Sending capabilities:); for (uint32_t i = 0 ; i caps_size; ++i) { vd_printf(%X, caps-caps[i]); -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win] vdagent: enable disabled monitor with default resolution
When enabling a disabled monitor, init_dev_mod() failed to create DC, and therefore due to the custom resolution received, in set_displays() No suitable mode found for display. Enabling with standard resoultion (800*600) solves the issue. rhbz #910634 --- vdagent/vdagent.cpp |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 24fe1f7..e2efb4e 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -672,6 +672,11 @@ bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port VDAgentMonConfig* mon = mon_config-monitors[i]; vd_printf(%d. %u*%u*%u (%d,%d) %u, i, mon-width, mon-height, mon-depth, mon-x, mon-y, !!(mon_config-flags VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS)); +if (!mode-get_attached()) { +vd_printf(%d. enable as 800*600); +mon-width = 800; +mon-height = 600; +} mode-set_res(mon-width, mon-height, mon-depth); if (mon_config-flags VD_AGENT_CONFIG_MONITORS_FLAG_USE_POS) { mode-set_pos(mon-x, mon-y); -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win PATCH] vdservice: add quotes to service path
for the case path contains a space, see CreateService() doc: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682450.aspx rhbz #918635 --- vdservice/vdservice.cpp |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 9134c4b..89e0dbb 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -170,12 +170,16 @@ bool VDService::install() printf(OpenSCManager failed\n); return false; } -TCHAR path[_MAX_PATH + 1]; -if (!GetModuleFileName(0, path, sizeof(path) / sizeof(path[0]))) { +TCHAR path[_MAX_PATH + 2]; +DWORD len = GetModuleFileName(0, path + 1, _MAX_PATH); +if (len == 0 || len == _MAX_PATH) { printf(GetModuleFileName failed\n); CloseServiceHandle(service_control_manager); return false; } +// add quotes for the case path contains a space (see CreateService doc) +path[0] = path[len + 1] = TEXT('\'); +path[len + 2] = 0; SC_HANDLE service = CreateService(service_control_manager, VD_SERVICE_NAME, VD_SERVICE_DISPLAY_NAME, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win 1/6] vdagent: on encoding only, use HBITMAP to keep the correct palette
for decoding, keep using CF_DIB and CxImage.CopyToHandle() as before. Regression was due to commit da07ce (rhbz #919150) rhbz #921980 --- vdagent/vdagent.cpp |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index c56025d..1dcfd1a 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -42,7 +42,7 @@ typedef struct VDClipboardFormat { VDClipboardFormat clipboard_formats[] = { {CF_UNICODETEXT, {VD_AGENT_CLIPBOARD_UTF8_TEXT, 0}}, //FIXME: support more image types -{CF_BITMAP, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}}, +{CF_DIB, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}}, }; #define clipboard_formats_count (sizeof(clipboard_formats) / sizeof(clipboard_formats[0])) @@ -1008,6 +1008,10 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques vd_printf(Unsupported clipboard type %u, clipboard_request-type); return false; } +// on encoding only, we use HBITMAP to keep the correct palette +if (format == CF_DIB) { +format = CF_BITMAP; +} if (!IsClipboardFormatAvailable(format) || !OpenClipboard(_hwnd)) { return false; } -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win 2/6] vdservice: extract supported_system_version() to vdcommon
rhbz #919451 preparation --- common/vdcommon.cpp| 36 common/vdcommon.h |8 vdservice/vdservice.cpp| 24 vdservice/vdservice.vcproj |4 4 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 common/vdcommon.cpp diff --git a/common/vdcommon.cpp b/common/vdcommon.cpp new file mode 100644 index 000..4dc50b4 --- /dev/null +++ b/common/vdcommon.cpp @@ -0,0 +1,36 @@ +/* + Copyright (C) 2013 Red Hat, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/. +*/ + +#include vdcommon.h + +int supported_system_version() +{ +OSVERSIONINFOEX osvi; + +ZeroMemory(osvi, sizeof(OSVERSIONINFOEX)); +osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); +if (!GetVersionEx((OSVERSIONINFO*)osvi)) { +vd_printf(GetVersionEx() failed: %lu, GetLastError()); +return 0; +} +if (osvi.dwMajorVersion == 5 (osvi.dwMinorVersion == 1 || osvi.dwMinorVersion == 2)) { +return SYS_VER_WIN_XP_CLASS; +} else if (osvi.dwMajorVersion == 6 osvi.dwMinorVersion = 0 osvi.dwMinorVersion = 2) { +return SYS_VER_WIN_7_CLASS; +} +return 0; +} diff --git a/common/vdcommon.h b/common/vdcommon.h index 605153d..177721c 100644 --- a/common/vdcommon.h +++ b/common/vdcommon.h @@ -51,5 +51,13 @@ typedef CRITICAL_SECTION mutex_t; #define _ftime_s(timeb) _ftime(timeb) #endif +enum SystemVersion { +SYS_VER_UNSUPPORTED, +SYS_VER_WIN_XP_CLASS, // also Server 2003/R2 +SYS_VER_WIN_7_CLASS, // also Windows 8, Server 2012, Server 2008/R2 Vista +}; + +int supported_system_version(); + #endif diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 90a3b26..9134c4b 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -119,30 +119,6 @@ VDService* VDService::get() return (VDService*)_singleton; } -enum SystemVersion { -SYS_VER_UNSUPPORTED, -SYS_VER_WIN_XP_CLASS, // also Server 2003/R2 -SYS_VER_WIN_7_CLASS, // also Windows 8, Server 2012, Server 2008/R2 Vista -}; - -int supported_system_version() -{ -OSVERSIONINFOEX osvi; - -ZeroMemory(osvi, sizeof(OSVERSIONINFOEX)); -osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); -if (!GetVersionEx((OSVERSIONINFO*)osvi)) { -vd_printf(GetVersionEx() failed: %lu, GetLastError()); -return 0; -} -if (osvi.dwMajorVersion == 5 (osvi.dwMinorVersion == 1 || osvi.dwMinorVersion == 2)) { -return SYS_VER_WIN_XP_CLASS; -} else if (osvi.dwMajorVersion == 6 osvi.dwMinorVersion = 0 osvi.dwMinorVersion = 2) { -return SYS_VER_WIN_7_CLASS; -} -return 0; -} - VDService::VDService() : _status_handle (0) , _events (NULL) diff --git a/vdservice/vdservice.vcproj b/vdservice/vdservice.vcproj index 45af4c5..736f425 100644 --- a/vdservice/vdservice.vcproj +++ b/vdservice/vdservice.vcproj @@ -363,6 +363,10 @@ UniqueIdentifier={4FC737F1-C7A5-4376-A066-2A32D752A2FF} File + RelativePath=..\common\vdcommon.cpp + + /File + File RelativePath=..\common\vdlog.cpp /File -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win 4/6] vdagent: log unsupported grabbed clipboard formats
rhbz #919451 debugging, useful anyway --- vdagent/vdagent.cpp | 11 --- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index b5d65cd..e20c830 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -914,13 +914,16 @@ bool VDAgent::write_message(uint32_t type, uint32_t size = 0, void* data = NULL) void VDAgent::on_clipboard_grab() { -uint32_t* types = new uint32_t[clipboard_formats_count * VD_CLIPBOARD_FORMAT_MAX_TYPES]; +uint32_t types[clipboard_formats_count * VD_CLIPBOARD_FORMAT_MAX_TYPES]; int count = 0; if (!VD_AGENT_HAS_CAPABILITY(_client_caps, _client_caps_size, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) { return; } +if (CountClipboardFormats() == 0) { +return; +} for (unsigned int i = 0; i clipboard_formats_count; i++) { if (IsClipboardFormatAvailable(clipboard_formats[i].format)) { for (uint32_t* ptype = clipboard_formats[i].types; *ptype; ptype++) { @@ -932,9 +935,11 @@ void VDAgent::on_clipboard_grab() write_message(VD_AGENT_CLIPBOARD_GRAB, count * sizeof(types[0]), types); set_clipboard_owner(owner_guest); } else { -vd_printf(Unsupported clipboard format); +UINT format = 0; +while (format = EnumClipboardFormats(format)) { +vd_printf(Unsupported clipboard format %u, format); +} } -delete[] types; } // In delayed rendering, Windows requires us to SetClipboardData before we return from -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win 5/6] vdagent: don't terminate if stop event cannot be opened
so vdagent can keep running as standalone without dependency on vdservice. Regression was due to commit c1807e. rhbz #903379 --- vdagent/vdagent.cpp | 22 +- 1 files changed, 9 insertions(+), 13 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index e20c830..f254d55 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -295,11 +295,6 @@ bool VDAgent::run() return false; } _stop_event = OpenEvent(SYNCHRONIZE, FALSE, VD_AGENT_STOP_EVENT); -if (!_stop_event) { -vd_printf(OpenEvent() failed: %lu, GetLastError()); -cleanup(); -return false; -} memset(wcls, 0, sizeof(wcls)); wcls.lpfnWndProc = VDAgent::wnd_proc; wcls.lpszClassName = VD_AGENT_WINCLASS_NAME; @@ -472,12 +467,19 @@ void VDAgent::input_desktop_message_loop() void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask) { -HANDLE events[] = {_control_event, _stop_event}; -const DWORD event_count = sizeof(events) / sizeof(events[0]); +HANDLE events[] = {_control_event, _stop_event}; +DWORD event_count = _stop_event ? 2 : 1; DWORD wait_ret; MSG msg; wait_ret = MsgWaitForMultipleObjectsEx(event_count, events, timeout, wake_mask, MWMO_ALERTABLE); +if (wait_ret == WAIT_OBJECT_0 + event_count) { +while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { +TranslateMessage(msg); +DispatchMessage(msg); +} +return; +} switch (wait_ret) { case WAIT_OBJECT_0: handle_control_event(); @@ -485,12 +487,6 @@ void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask) case WAIT_OBJECT_0 + 1: _running = false; break; -case WAIT_OBJECT_0 + event_count: -while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { -TranslateMessage(msg); -DispatchMessage(msg); -} -break; case WAIT_IO_COMPLETION: case WAIT_TIMEOUT: break; -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win 6/6] vdagent: add vdagent_helper to support mouse when UAC dialog takes focus
Running the helper with ShellExecute(...runas...) is the way to SendInput() to the UAC dialog in Windows Vista and above. http://stackoverflow.com/questions/2426594/starting-a-uac-elevated-process- from-a-non-interactive-service-win32-net-power http://www.microsoft-questions.com/microsoft/Platform-SDK-Security/29620442/ how-to-proper-use-sendinput-to-a-elevated-window-from-a-service.aspx rhbz #908422 --- common/vdcommon.h|1 + vdagent.sln | 10 + vdagent/vdagent.cpp | 51 +- vdagent_helper/vdagent_helper.cpp| 46 + vdagent_helper/vdagent_helper.vcproj | 363 ++ 5 files changed, 470 insertions(+), 1 deletions(-) create mode 100644 vdagent_helper/vdagent_helper.cpp create mode 100644 vdagent_helper/vdagent_helper.vcproj diff --git a/common/vdcommon.h b/common/vdcommon.h index 177721c..5099fdc 100644 --- a/common/vdcommon.h +++ b/common/vdcommon.h @@ -34,6 +34,7 @@ typedef CRITICAL_SECTION mutex_t; #define VD_AGENT_REGISTRY_KEY SOFTWARE\\Red Hat\\Spice\\vdagent\\ #define VD_AGENT_STOP_EVENT TEXT(Global\\vdagent_stop_event) +#define VD_AGENT_NAMED_PIPE TEXT(.\\pipe\\vdagent) #if defined __GNUC__ #define ALIGN_GCC __attribute__ ((packed)) diff --git a/vdagent.sln b/vdagent.sln index 2622f2e..0848ced 100644 --- a/vdagent.sln +++ b/vdagent.sln @@ -5,6 +5,8 @@ Project({8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = vdagent, vdagent\vdagent. EndProject Project({8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = vdservice, vdservice\vdservice.vcproj, {ADFE5E22-31D0-4343-AE9E-8102CC0051F9} EndProject +Project({8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = vdagent_helper, vdagent_helper\vdagent_helper.vcproj, {3E459EA7-0252-48E0-A92B-13A66F5F370B} +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -29,6 +31,14 @@ Global {ADFE5E22-31D0-4343-AE9E-8102CC0051F9}.Release|Win32.Build.0 = Release|Win32 {ADFE5E22-31D0-4343-AE9E-8102CC0051F9}.Release|x64.ActiveCfg = Release|x64 {ADFE5E22-31D0-4343-AE9E-8102CC0051F9}.Release|x64.Build.0 = Release|x64 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Debug|Win32.ActiveCfg = Debug|Win32 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Debug|Win32.Build.0 = Debug|Win32 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Debug|x64.ActiveCfg = Debug|x64 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Debug|x64.Build.0 = Debug|x64 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Release|Win32.ActiveCfg = Release|Win32 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Release|Win32.Build.0 = Release|Win32 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Release|x64.ActiveCfg = Release|x64 + {3E459EA7-0252-48E0-A92B-13A66F5F370B}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index f254d55..24fe1f7 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -111,6 +111,7 @@ private: bool write_message(uint32_t type, uint32_t size, void* data); bool write_clipboard(VDAgentMessage* msg, uint32_t size); bool init_vio_serial(); +bool launch_helper(); bool send_input(); void set_display_depth(uint32_t depth); void load_display_setting(); @@ -133,6 +134,7 @@ private: ULONG _mouse_y; INPUT _input; DWORD _input_time; +HANDLE _helper_pipe; HANDLE _control_event; HANDLE _stop_event; VDAgentMessage* _in_msg; @@ -189,6 +191,7 @@ VDAgent::VDAgent() , _mouse_x (0) , _mouse_y (0) , _input_time (0) +, _helper_pipe (NULL) , _control_event (NULL) , _stop_event (NULL) , _in_msg (NULL) @@ -287,6 +290,10 @@ bool VDAgent::run() cleanup(); return false; } +if (!launch_helper()) { +cleanup(); +return false; +} } _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!_control_event) { @@ -342,6 +349,7 @@ bool VDAgent::run() void VDAgent::cleanup() { FreeLibrary(_user_lib); +CloseHandle(_helper_pipe); CloseHandle(_stop_event); CloseHandle(_control_event); CloseHandle(_vio_serial); @@ -393,6 +401,37 @@ void VDAgent::handle_control_event() MUTEX_UNLOCK(_control_mutex); } +bool VDAgent::launch_helper() +{ +HINSTANCE helper; +TCHAR helper_path[MAX_PATH]; +TCHAR* slash; + +if (!GetModuleFileName(NULL, helper_path, MAX_PATH) || + !(slash = wcsrchr(helper_path, TCHAR('\\' { +vd_printf(Cannot get file path: %lu, GetLastError()); +} +wcscpy(slash + 1, Lvdagent_helper.exe); +helper = ShellExecute(NULL, Lrunas, helper_path, NULL, NULL, SW_HIDE); +if (helper =
[Spice-devel] [PATCH vdagent-win 3/6] vdagent: for Win7 class, use ClipboardFormatListener api
(Win7 class includes Win8/Vista/Server2012/Server2008/R2) This new api was introduced in Vista/2K8 to keep track of clipboard changes, without the need to trust the (mis)behavior of other applications registered to the clipboard. If the issue is reproduced on XP as well, it can be hacked by a periodic call to ChangeClipboardChain SetClipboardViewer as described in http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/ 521183dc-7872-472e-8104-8c0d75b1bf53 rhbz #919451 --- vdagent/vdagent.cpp| 40 ++-- vdagent/vdagent.vcproj |4 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 1dcfd1a..b5d65cd 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -65,6 +65,8 @@ typedef struct ALIGN_VC VDIChunk { #define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage)) #define VD_READ_BUF_SIZE (sizeof(VDIChunk) + VD_AGENT_MAX_DATA_SIZE) +typedef BOOL (WINAPI *PCLIPBOARD_OP)(HWND); + class VDAgent { public: static VDAgent* get(); @@ -120,6 +122,10 @@ private: static VDAgent* _singleton; HWND _hwnd; HWND _hwnd_next_viewer; +HMODULE _user_lib; +PCLIPBOARD_OP _add_clipboard_listener; +PCLIPBOARD_OP _remove_clipboard_listener; +int _system_version; int _clipboard_owner; DWORD _clipboard_tick; DWORD _buttons_state; @@ -174,6 +180,9 @@ VDAgent* VDAgent::get() VDAgent::VDAgent() : _hwnd (NULL) , _hwnd_next_viewer (NULL) +, _user_lib (NULL) +, _add_clipboard_listener (NULL) +, _remove_clipboard_listener (NULL) , _clipboard_owner (owner_none) , _clipboard_tick (0) , _buttons_state (0) @@ -201,6 +210,7 @@ VDAgent::VDAgent() TCHAR log_path[MAX_PATH]; TCHAR temp_path[MAX_PATH]; +_system_version = supported_system_version(); if (GetTempPath(MAX_PATH, temp_path)) { swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path); _log = VDLog::get(log_path); @@ -262,6 +272,22 @@ bool VDAgent::run() if (!SetProcessShutdownParameters(0x100, 0)) { vd_printf(SetProcessShutdownParameters failed %lu, GetLastError()); } +if (_system_version == SYS_VER_WIN_7_CLASS) { +_user_lib = LoadLibrary(LUser32.dll); +if (!_user_lib) { +vd_printf(LoadLibrary failed %lu, GetLastError()); +return false; +} +_add_clipboard_listener = +(PCLIPBOARD_OP)GetProcAddress(_user_lib, AddClipboardFormatListener); +_remove_clipboard_listener = +(PCLIPBOARD_OP)GetProcAddress(_user_lib, RemoveClipboardFormatListener); +if (!_add_clipboard_listener || !_remove_clipboard_listener) { +vd_printf(GetProcAddress failed %lu, GetLastError()); +cleanup(); +return false; +} +} _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (!_control_event) { vd_printf(CreateEvent() failed: %lu, GetLastError()); @@ -320,6 +346,7 @@ bool VDAgent::run() void VDAgent::cleanup() { +FreeLibrary(_user_lib); CloseHandle(_stop_event); CloseHandle(_control_event); CloseHandle(_vio_serial); @@ -420,7 +447,11 @@ void VDAgent::input_desktop_message_loop() if (!WTSRegisterSessionNotification(_hwnd, NOTIFY_FOR_ALL_SESSIONS)) { vd_printf(WTSRegisterSessionNotification() failed: %lu, GetLastError()); } -_hwnd_next_viewer = SetClipboardViewer(_hwnd); +if (_system_version == SYS_VER_WIN_7_CLASS) { +_add_clipboard_listener(_hwnd); +} else { +_hwnd_next_viewer = SetClipboardViewer(_hwnd); +} while (_running !_desktop_switch) { event_dispatcher(INFINITE, QS_ALLINPUT); } @@ -429,7 +460,11 @@ void VDAgent::input_desktop_message_loop() KillTimer(_hwnd, VD_TIMER_ID); _pending_input = false; } -ChangeClipboardChain(_hwnd, _hwnd_next_viewer); +if (_system_version == SYS_VER_WIN_7_CLASS) { +_remove_clipboard_listener(_hwnd); +} else { +ChangeClipboardChain(_hwnd, _hwnd_next_viewer); +} WTSUnRegisterSessionNotification(_hwnd); DestroyWindow(_hwnd); CloseDesktop(hdesk); @@ -1343,6 +1378,7 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA SendMessage(a-_hwnd_next_viewer, message, wparam, lparam); } break; +case WM_CLIPBOARDUPDATE: case WM_DRAWCLIPBOARD: if (a-_hwnd != GetClipboardOwner()) { a-set_clipboard_owner(a-owner_none); diff --git a/vdagent/vdagent.vcproj b/vdagent/vdagent.vcproj index 5e7bb43..ed8c58d 100644 --- a/vdagent/vdagent.vcproj +++ b/vdagent/vdagent.vcproj @@ -354,6 +354,10 @@ /File File + RelativePath=..\common\vdcommon.cpp + +
[Spice-devel] [vdagent-win PATCH] vdagent: use HBITMAP instead of DIB for image encoding
CxImage DIB to PNG encoding seems to ignore pallete in some scenarios. This issue happens when copying a png from FireFox, but with IE it's ok. rhbz #919150 --- vdagent/vdagent.cpp | 11 --- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 722815c..6f2a49c 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -42,7 +42,7 @@ typedef struct VDClipboardFormat { VDClipboardFormat clipboard_formats[] = { {CF_UNICODETEXT, {VD_AGENT_CLIPBOARD_UTF8_TEXT, 0}}, //FIXME: support more image types -{CF_DIB, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}}, +{CF_BITMAP, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}}, }; #define clipboard_formats_count (sizeof(clipboard_formats) / sizeof(clipboard_formats[0])) @@ -1025,8 +1025,13 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques case VD_AGENT_CLIPBOARD_IMAGE_PNG: case VD_AGENT_CLIPBOARD_IMAGE_BMP: { DWORD cximage_format = get_cximage_format(clipboard_request-type); -ASSERT(cximage_format); -if (!image.CreateFromHANDLE(clip_data)) { +HPALETTE pal = 0; + +ASSERT(cximage_format); +if (IsClipboardFormatAvailable(CF_PALETTE)) { +pal = (HPALETTE)GetClipboardData(CF_PALETTE); +} +if (!image.CreateFromHBITMAP((HBITMAP)clip_data, pal)) { vd_printf(Image create from handle failed); break; } -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [vdagent-win PATCH] vdservice: reset vdagent stop event after wait
vdagent terminates when the global event is set by vdservice. vdservice is also responsible to reset the event in any case, without trusting vdagent to do so. Otherwise, it may terminate the following vdagent instance immediately as well. Regression was due to commit 2d03cc. rhbz #868254 --- vdservice/vdservice.cpp |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index a899ae1..90a3b26 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -801,6 +801,7 @@ bool VDService::kill_agent() break; } } +ResetEvent(_agent_stop_event); CloseHandle(proc_handle); CloseHandle(_agent_proc_info.hThread); ZeroMemory(_agent_proc_info, sizeof(_agent_proc_info)); -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH vdagent-win] vdservice stops vdagent via event
Terminate agent politely instead of ugly TerminateProcess(), so now VD_AGENT_CLIPBOARD_RELEASE is sent (if guest owned the clipboard), followed by cleanup. rhbz #903379 --- common/vdcommon.h |1 + vdagent/vdagent.cpp | 16 +++- vdservice/vdservice.cpp |5 - 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/vdcommon.h b/common/vdcommon.h index cc3bd3d..605153d 100644 --- a/common/vdcommon.h +++ b/common/vdcommon.h @@ -33,6 +33,7 @@ typedef CRITICAL_SECTION mutex_t; #define MUTEX_UNLOCK(mutex) LeaveCriticalSection(mutex) #define VD_AGENT_REGISTRY_KEY SOFTWARE\\Red Hat\\Spice\\vdagent\\ +#define VD_AGENT_STOP_EVENT TEXT(Global\\vdagent_stop_event) #if defined __GNUC__ #define ALIGN_GCC __attribute__ ((packed)) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 85244c0..722815c 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -128,6 +128,7 @@ private: INPUT _input; DWORD _input_time; HANDLE _control_event; +HANDLE _stop_event; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; bool _pending_input; @@ -180,6 +181,7 @@ VDAgent::VDAgent() , _mouse_y (0) , _input_time (0) , _control_event (NULL) +, _stop_event (NULL) , _in_msg (NULL) , _in_msg_pos (0) , _pending_input (false) @@ -266,6 +268,12 @@ bool VDAgent::run() cleanup(); return false; } +_stop_event = OpenEvent(SYNCHRONIZE, FALSE, VD_AGENT_STOP_EVENT); +if (!_stop_event) { +vd_printf(OpenEvent() failed: %lu, GetLastError()); +cleanup(); +return false; +} memset(wcls, 0, sizeof(wcls)); wcls.lpfnWndProc = VDAgent::wnd_proc; wcls.lpszClassName = VD_AGENT_WINCLASS_NAME; @@ -312,6 +320,7 @@ bool VDAgent::run() void VDAgent::cleanup() { +CloseHandle(_stop_event); CloseHandle(_control_event); CloseHandle(_vio_serial); delete _desktop_layout; @@ -428,15 +437,20 @@ void VDAgent::input_desktop_message_loop() void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask) { +HANDLE events[] = {_control_event, _stop_event}; +const DWORD event_count = sizeof(events) / sizeof(events[0]); DWORD wait_ret; MSG msg; -wait_ret = MsgWaitForMultipleObjectsEx(1, _control_event, timeout, wake_mask, MWMO_ALERTABLE); +wait_ret = MsgWaitForMultipleObjectsEx(event_count, events, timeout, wake_mask, MWMO_ALERTABLE); switch (wait_ret) { case WAIT_OBJECT_0: handle_control_event(); break; case WAIT_OBJECT_0 + 1: +_running = false; +break; +case WAIT_OBJECT_0 + event_count: while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(msg); DispatchMessage(msg); diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index a2cf67d..a899ae1 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -92,6 +92,7 @@ private: SERVICE_STATUS_HANDLE _status_handle; PROCESS_INFORMATION _agent_proc_info; HANDLE _control_event; +HANDLE _agent_stop_event; HANDLE* _events; TCHAR _agent_path[MAX_PATH]; VDControlQueue _control_queue; @@ -157,6 +158,7 @@ VDService::VDService() ZeroMemory(_agent_proc_info, sizeof(_agent_proc_info)); _system_version = supported_system_version(); _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); +_agent_stop_event = CreateEvent(NULL, FALSE, FALSE, VD_AGENT_STOP_EVENT); _agent_path[0] = wchar_t('\0'); MUTEX_INIT(_agent_mutex); MUTEX_INIT(_control_mutex); @@ -165,6 +167,7 @@ VDService::VDService() VDService::~VDService() { +CloseHandle(_agent_stop_event); CloseHandle(_control_event); delete _events; delete _log; @@ -777,7 +780,7 @@ bool VDService::kill_agent() _agent_alive = false; proc_handle = _agent_proc_info.hProcess; _agent_proc_info.hProcess = 0; -TerminateProcess(proc_handle, 0); +SetEvent(_agent_stop_event); if (GetProcessId(proc_handle)) { wait_ret = WaitForSingleObject(proc_handle, VD_AGENT_TIMEOUT); switch (wait_ret) { -- 1.7.7.6 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] using spice together with rdp, problem with mouse
which vdagent version are you using? which windows version? please send %windir%\temp\vdagemt.log vdservice.log. I guess it's something to do with the different sessions used by spice rdp. flooding Controlled wrote: I do not know how you can use spice and RDP together, can you explain your situation? However, I think you'd better put them into different channels. 2012/12/12 me,apporc appleorchard2...@gmail.com Hi, We use spice together with rdp, in our production envrionment. Because it is well to use spice with playing video, but the spice client in windows doesn't support usb redirection by now. In our environment, our clients want to use them together. Problem is that, every time they switch from rdp to spice when connecting a windows virtual machine, they can't use their mouse with spice, but the keyboard is ok. And, when they can't use mouse in that situation, they can restart the RHEV spice agent service, just stop it (as if it is running) or start it (as if it is stopped), then the mouse will be ok . Does anyone have some advice about this, if it is an unknown bug, then how could we debug this. Could someone give us some direction. Thanks. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH] build-sys: remove *vdi_port* from Makefile.am
--- Makefile.am |6 -- 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9b73def..3bd66aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,13 +31,7 @@ vdagent_SOURCES =\ vdagent/desktop_layout.h\ vdagent/display_setting.cpp \ vdagent/display_setting.h \ - vdagent/pci_vdi_port.cpp\ - vdagent/pci_vdi_port.h \ vdagent/vdagent.cpp \ - vdagent/vdi_port.cpp\ - vdagent/vdi_port.h \ - vdagent/virtio_vdi_port.cpp \ - vdagent/virtio_vdi_port.h \ $(NULL) vdagent_rc.$(OBJEXT): vdagent/vdagent.rc -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] cut/paste failure on Windows 7 guest
Han Pilmeyer wrote: Thanks for your efforts Arnon, On 02/12/2012 08:23, Arnon Gilboa wrote: Lots of virtio-serial driver bugs, which are very relevant to cut/paste, were recently fixed. The driver on the above link seem to be outdated. I'll try to find a link for an updated upstream version. Note that the driver came from the recently released spice-guest-0.2.exe, which seems to be the same version as was available in the RHEV 3.0 release. I'm not sure whether the 3.1 beta would have a newer driver. 3.1 beta has a newer driver, exactly with the relevant fixes for cp. Anyway, in order to debug it online, catch us on #spice at irc.gimp.net/6667 I'm in the room now, but I'll be travelling a lot over the next 3 weeks, so I will not be online often unfortunately. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] cut/paste failure on Windows 7 guest
Hi Han, Han Pilmeyer wrote: Where would you like me to report back? Here or on the list? list, cc'ed What I'm mainly concerned about is losing accenot sure it's thess to the mouse. If that happens, I can not easily fix the guest image. can you send the logs from this scenario? you can always shutdown using keyboard;) On my test guest it worked after restarting the service with the new executables (but it worked before as well) and also on the 2nd reboot. ok On the 1st reboot I had one of my other issues, namely that the vdagent doesn't start. this seems to be virtio-serial issue. what are the versions of the driver and qemu? That could seems to have changed as there now appear to be retries every 3 seconds for a bit of time. Below is the log of that: not sure it's the right behavior, or it's a leftover. i'll consider removing the retries. 2580::INFO::2012-11-29 17:34:43,610::log_version::0.5.1.0 2580::INFO::2012-11-29 17:34:43,610::DesktopLayout::consistent_displays::#qxls 1 #others 0 2580::INFO::2012-11-29 17:34:43,610::VDAgent::send_announce_capabilities::Sending capabilities: 2580::INFO::2012-11-29 17:34:43,610::VDAgent::send_announce_capabilities::37 2580::INFO::2012-11-29 17:34:43,610::VDAgent::run::Connected to server 2580::INFO::2012-11-29 17:34:43,610::VDAgent::input_desktop_message_loop::Desktop: Winlogon 2580::INFO::2012-11-29 17:34:43,610::VDAgent::handle_announce_capabilities::Got capabilities (1) 2580::INFO::2012-11-29 17:34:43,610::VDAgent::handle_announce_capabilities::77 2580::INFO::2012-11-29 17:34:43,610::VDAgent::send_announce_capabilities::Sending capabilities: 2580::INFO::2012-11-29 17:34:43,610::VDAgent::send_announce_capabilities::37 2580::INFO::2012-11-29 17:34:43,610::VDAgent::handle_announce_capabilities::Got capabilities (1) 2580::INFO::2012-11-29 17:34:43,610::VDAgent::handle_announce_capabilities::77 2580::INFO::2012-11-29 17:34:43,610::DisplaySetting::set::setting display options 2580::INFO::2012-11-29 17:34:43,610::DisplaySetting::get_user_process_id::explorer.exe not found 2580::INFO::2012-11-29 17:34:43,610::DisplaySetting::reload_from_registry::get_user_process_id failed 792::INFO::2012-11-29 17:35:35,725::VDAgent::run::***Agent started in session 1*** 792::INFO::2012-11-29 17:35:35,725::log_version::0.5.1.0 792::INFO::2012-11-29 17:35:35,725::DesktopLayout::consistent_displays::#qxls 1 #others 0 792::INFO::2012-11-29 17:35:35,725::VDAgent::init_vio_serial::Failed opening \\.\Global\com.redhat.spice.0, error 2 1188::INFO::2012-11-29 17:35:37,914::VDAgent::run::***Agent started in session 1*** 1188::INFO::2012-11-29 17:35:37,915::log_version::0.5.1.0 1188::INFO::2012-11-29 17:35:37,916::DesktopLayout::consistent_displays::#qxls 1 #others 0 1188::INFO::2012-11-29 17:35:37,916::VDAgent::init_vio_serial::Failed opening \\.\Global\com.redhat.spice.0, error 2 1660::INFO::2012-11-29 17:35:40,937::VDAgent::run::***Agent started in session 1*** 1660::INFO::2012-11-29 17:35:40,937::log_version::0.5.1.0 1660::INFO::2012-11-29 17:35:40,937::DesktopLayout::consistent_displays::#qxls 1 #others 0 1660::INFO::2012-11-29 17:35:40,937::VDAgent::init_vio_serial::Failed opening \\.\Global\com.redhat.spice.0, error 2 1956::INFO::2012-11-29 17:35:44,030::VDAgent::run::***Agent started in session 1*** not sure the 1956::INFO::2012-11-29 17:35:44,030::log_version::0.5.1.0 1956::INFO::2012-11-29 17:35:44,030::DesktopLayout::consistent_displays::#qxls 1 #others 0 1956::INFO::2012-11-29 17:35:44,030::VDAgent::init_vio_serial::Failed opening \\.\Global\com.redhat.spice.0, error 2 2152::INFO::2012-11-29 17:35:47,056::VDAgent::run::***Agent started in session 1*** 2152::INFO::2012-11-29 17:35:48,694::log_version::0.5.1.0 2152::INFO::2012-11-29 17:35:48,694::DesktopLayout::consistent_displays::#qxls 1 #others 0 2152::INFO::2012-11-29 17:35:48,694::VDAgent::init_vio_serial::Failed opening \\.\Global\com.redhat.spice.0, error 2 2332::INFO::2012-11-29 17:35:51,830::VDAgent::run::***Agent started in session 1*** On 29/11/2012 17:27, Arnon Gilboa wrote: Han Pilmeyer wrote: Arnon, Just a quick question before I do something stupid. I just tried placing the exe's in the proper location and restarting the service. It didn't work. update should be done after stopping g the service (verify that vdservice vdagent are not running), then start it. if it doesn't help, try to restart your vm. anyway please send the relevant lines of both vdagent vdservice logs. There were some different messages in the log (compared to previous logs), but my feeling was that the cut/paste was completely ignored. I was tempted to reboot to make sure, but I noticed that my mouse didn't work when I stopped the service. This would make my guest virtually useless. Is there a proper/safe way to test this? I'm going to retry with a test guest now. Cheers, Han ___ Spice-devel mailing list Spice-devel
Re: [Spice-devel] cut/paste failure on Windows 7 guest
Han Pilmeyer wrote: On 29/11/2012 13:58, Christophe Fergeau wrote: On Thu, Nov 29, 2012 at 12:56:49PM +0200, Arnon Gilboa wrote: Han Pilmeyer wrote: However both yesterday and today, the guest refuses to do cut/paste between the guest and host. Below I have the relevant portion of the vdagent.log. I guess the on_clipboard_request::wait timeout.. messages at the end are the key part. If there is anything I can do to help resolve this issue, feel free to contact me. was it a large paste? this patch seem to fix it. http://cgit.freedesktop.org/spice/win32/vd_agent/commit/?id=a69af07d build vdagent vdservice, update yours and use newer virtio-serial driver. http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers spice-guest-tools-0.2.exe already have the latest vioserial driver from https://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/ , but it seems the vioserial driver in there has known bugs... Arnon was kind enough to build me a fresh vdagent and vdservice. With those, the messages seem to have disappeared or at least changed, but cut/paste still is not working. In fact several reboots later it hasn't worked once, which is worse than the original. I'm pretty sure that I am using the correct version as the messages have time stamps again and it also seems that the UI on Windows visibly indicates after 3 seconds or so that it failed (this used to be more than 10 seconds). Below are the messages recorded in both the vdservice.log and the vdagent.log. I tried to paste from the host to the guest immediately after I unlocked the guest screen (UNLOCK message in the vdservice.log); vdservice.log: 700::INFO::2012-11-30 11:02:56,020::log_version::0.5.1.0 700::INFO::2012-11-30 11:02:56,020::VDService::execute::Active console session id: 1 700::INFO::2012-11-30 11:02:56,300::VDService::execute::Connect state: 2 688::INFO::2012-11-30 11:03:00,419::VDService::control_handler::Session 1 CONNECT 688::INFO::2012-11-30 11:04:19,499::VDService::control_handler::Session 1 LOGON 688::INFO::2012-11-30 11:44:42,845::VDService::control_handler::Session 1 LOCK 688::INFO::2012-11-30 12:17:03,477::VDService::control_handler::Session 1 UNLOCK 688::INFO::2012-11-30 12:34:30,357::VDService::control_handler::Session 1 LOCK 688::INFO::2012-11-30 14:25:34,782::VDService::control_handler::Session 1 UNLOCK vdagent.log: 340::INFO::2012-11-30 12:16:46,807::VDAgent::handle_clipboard_grab::grab type 1 340::INFO::2012-11-30 12:17:05,158::VDAgent::handle_control_event::Control command 1 340::INFO::2012-11-30 12:17:05,236::VDAgent::input_desktop_message_loop::Desktop: Default 340::INFO::2012-11-30 12:17:05,407::VDAgent::on_clipboard_grab::Unsupported clipboard format 340::INFO::2012-11-30 12:29:25,989::VDAgent::handle_control_event::Control command 1 340::INFO::2012-11-30 12:29:26,004::VDAgent::input_desktop_message_loop::Desktop: Screen-saver 340::INFO::2012-11-30 12:29:26,004::VDAgent::on_clipboard_grab::Unsupported clipboard format 340::INFO::2012-11-30 12:34:27,228::VDAgent::handle_control_event::Control command 1 340::INFO::2012-11-30 12:34:27,243::VDAgent::input_desktop_message_loop::Desktop: Winlogon 340::INFO::2012-11-30 12:34:27,243::VDAgent::on_clipboard_grab::Unsupported clipboard format 340::INFO::2012-11-30 13:24:56,265::VDAgent::handle_clipboard_release::Received clipboard release from client while clipboard is not owned by client 340::INFO::2012-11-30 13:24:56,421::VDAgent::handle_clipboard_grab::grab type 1 340::INFO::2012-11-30 13:24:58,930::VDAgent::handle_control_event::Control command 3 340::INFO::2012-11-30 14:18:35,166::VDAgent::handle_clipboard_grab::grab type 1 340::INFO::2012-11-30 14:18:38,584::VDAgent::handle_control_event::Control command 3 340::INFO::2012-11-30 14:25:35,055::VDAgent::handle_control_event::Control command 1 340::INFO::2012-11-30 14:25:35,231::VDAgent::input_desktop_message_loop::Desktop: Default 340::INFO::2012-11-30 14:25:35,253::VDAgent::on_clipboard_grab::Unsupported clipboard format 340::INFO::2012-11-30 14:25:51,254::VDAgent::handle_clipboard_grab::grab type 1 340::INFO::2012-11-30 14:26:00,009::VDAgent::on_clipboard_request::Clipboard wait timeout 340::INFO::2012-11-30 14:26:03,021::VDAgent::on_clipboard_request::Clipboard wait timeout Hi Han, Lots of virtio-serial driver bugs, which are very relevant to cut/paste, were recently fixed. The driver on the above link seem to be outdated. I'll try to find a link for an updated upstream version. Anyway, in order to debug it online, catch us on #spice at irc.gimp.net/6667 Thanks, Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] cut/paste failure on Windows 7 guest
Han Pilmeyer wrote: Hi, This last Tuesday I had a full day when cut/paste between my Windows 7 guest and Fedora 17 KVM host worked flawlessly. So I had high hopes that the spice-guest-0.2.exe drivers had indeed fixed my issues. However both yesterday and today, the guest refuses to do cut/paste between the guest and host. Below I have the relevant portion of the vdagent.log. I guess the on_clipboard_request::wait timeout.. messages at the end are the key part. If there is anything I can do to help resolve this issue, feel free to contact me. was it a large paste? this patch seem to fix it. http://cgit.freedesktop.org/spice/win32/vd_agent/commit/?id=a69af07d build vdagent vdservice, update yours and use newer virtio-serial driver. http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers 336::INFO::,000::run::***Agent started in session 1*** 336::INFO::,000::log_version::0.5.1.0 336::INFO::,000::consistent_displays::#qxls 0 #others 1 336::INFO::,000::connect_pipe::Connected to service pipe 336::INFO::,000::send_announce_capabilities::Sending capabilities: 336::INFO::,000::send_announce_capabilities::37 336::INFO::,000::input_desktop_message_loop::Desktop: Winlogon 336::INFO::,000::handle_announce_capabilities::Got capabilities (1) 336::INFO::,000::handle_announce_capabilities::77 336::INFO::,000::send_announce_capabilities::Sending capabilities: 336::INFO::,000::send_announce_capabilities::37 336::INFO::,000::set::setting display options 336::INFO::,000::get_user_process_id::explorer.exe not found 336::INFO::,000::reload_from_registry::get_user_process_id failed 336::INFO::,000::handle_control::session logon 336::INFO::,000::handle_control_event::Control command 1 336::INFO::,000::input_desktop_message_loop::Desktop: Default 336::INFO::,000::input_desktop_message_loop::First display setting 336::INFO::,000::load::loading display setting 336::INFO::,000::reload_from_registry::explorer pid 3772 336::INFO::,000::reload_wallpaper:: 336::INFO::,000::reload_wallpaper::wallpaper wasn't disabled 336::INFO::,000::reload_font_smoothing:: 336::INFO::,000::reload_font_smoothing::font smoothing value didn't change 336::INFO::,000::reload_animation:: 336::INFO::,000::reload_win_animation:: 336::INFO::,000::reload_win_animation::reload window animation: success 336::INFO::,000::reload_ui_effects:: 336::INFO::,000::reload_ui_effects::UserPreferencesMask = 80073e9e 12 336::INFO::,000::on_clipboard_grab::Unsupported clipboard format 336::INFO::,000::handle_clipboard_grab::grab type 1 336::INFO::,000::on_clipboard_request::wait timeout.. 336::INFO::,000::on_clipboard_request::wait timeout.. 336::INFO::,000::on_clipboard_request::wait timeout.. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH 1/3] vdagent: remove vdi_port, use vio_serial directly
seems ok, feel free to review ;) Arnon Gilboa wrote: NACK, seems it needs some more testing Arnon Gilboa wrote: --- vdagent/vdagent.cpp | 239 +++ 1 files changed, 109 insertions(+), 130 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 2bb466d..85244c0 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -16,8 +16,6 @@ */ #include vdcommon.h -#include virtio_vdi_port.h -#include pci_vdi_port.h #include desktop_layout.h #include display_setting.h #include ximage.h @@ -65,11 +63,7 @@ typedef struct ALIGN_VC VDIChunk { } ALIGN_GCC VDIChunk; #define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage)) - -enum { - VD_EVENT_CONTROL = 0, - VD_STATIC_EVENTS_COUNT // Must be last -}; +#define VD_READ_BUF_SIZE (sizeof(VDIChunk) + VD_AGENT_MAX_DATA_SIZE) class VDAgent { public: @@ -90,8 +84,6 @@ private: bool handle_clipboard_request(VDAgentClipboardRequest* clipboard_request); void handle_clipboard_release(); bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port); - void handle_port_in(); - void handle_port_out(); void handle_chunk(VDIChunk* chunk); void on_clipboard_grab(); void on_clipboard_request(UINT format); @@ -101,7 +93,9 @@ private: static HGLOBAL utf8_alloc(LPCSTR data, int size); static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); static DWORD WINAPI event_thread_proc(LPVOID param); - static void dispatch_message(VDAgentMessage* msg, uint32_t port); + static VOID CALLBACK read_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); + static VOID CALLBACK write_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); + void dispatch_message(VDAgentMessage* msg, uint32_t port); uint32_t get_clipboard_format(uint32_t type); uint32_t get_clipboard_type(uint32_t format); DWORD get_cximage_format(uint32_t type); @@ -114,7 +108,7 @@ private: void enqueue_chunk(VDIChunk* msg); bool write_message(uint32_t type, uint32_t size, void* data); bool write_clipboard(VDAgentMessage* msg, uint32_t size); - bool init_vdi_port(); + bool init_vio_serial(); bool send_input(); void set_display_depth(uint32_t depth); void load_display_setting(); @@ -134,16 +128,19 @@ private: INPUT _input; DWORD _input_time; HANDLE _control_event; - HANDLE* _events; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; - uint32_t _events_count; bool _pending_input; bool _running; bool _desktop_switch; DesktopLayout* _desktop_layout; DisplaySetting _display_setting; - VDIPort* _vdi_port; + HANDLE _vio_serial; + OVERLAPPED _read_overlapped; + OVERLAPPED _write_overlapped; + CHAR _read_buf[VD_READ_BUF_SIZE]; + DWORD _read_pos; + DWORD _write_pos; mutex_t _control_mutex; mutex_t _message_mutex; std::queueint _control_queue; @@ -163,6 +160,8 @@ private: VDAgent* VDAgent::_singleton = NULL; +#define VIOSERIAL_PORT_PATH L.\\Global\\com.redhat.spice.0 + VDAgent* VDAgent::get() { if (!_singleton) { @@ -181,16 +180,16 @@ VDAgent::VDAgent() , _mouse_y (0) , _input_time (0) , _control_event (NULL) - , _events (NULL) , _in_msg (NULL) , _in_msg_pos (0) - , _events_count (0) , _pending_input (false) , _running (false) , _desktop_switch (false) , _desktop_layout (NULL) , _display_setting (VD_AGENT_REGISTRY_KEY) - , _vdi_port (NULL) + , _vio_serial (NULL) + , _read_pos (0) + , _write_pos (0) , _logon_desktop (false) , _display_setting_initialized (false) , _client_caps (NULL) @@ -204,7 +203,10 @@ VDAgent::VDAgent() swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path); _log = VDLog::get(log_path); } - ZeroMemory(_input, sizeof(INPUT)); + ZeroMemory(_input, sizeof(_input)); + ZeroMemory(_read_overlapped, sizeof(_read_overlapped)); + ZeroMemory(_write_overlapped, sizeof(_write_overlapped)); + ZeroMemory(_read_buf, sizeof(_read_buf)); MUTEX_INIT(_control_mutex); MUTEX_INIT(_message_mutex); @@ -213,7 +215,6 @@ VDAgent::VDAgent() VDAgent::~VDAgent() { - delete _events; delete _log; delete[] _client_caps; } @@ -277,8 +278,13 @@ bool VDAgent::run() if (_desktop_layout-get_display_count() == 0) { vd_printf(No QXL devices!); } - if (!init_vdi_port()) { - vd_printf(Failed to create VDIPort instance); + if (!init_vio_serial()) { + cleanup(); + return false; + } + if (!ReadFileEx(_vio_serial, _read_buf, sizeof(VDIChunk), _read_overlapped, read_completion) + GetLastError() != ERROR_IO_PENDING) { + vd_printf(vio_serial read error %lu, GetLastError()); cleanup(); return false; } @@ -290,12 +296,6 @@ bool VDAgent::run() return false; } send_announce_capabilities(true); - - _events_count = VD_STATIC_EVENTS_COUNT + _vdi_port-get_num_events(); - _events = new HANDLE[_events_count]; - ZeroMemory(_events, _events_count); - _events[VD_EVENT_CONTROL] = _control_event; - _vdi_port-fill_events(_events[VD_STATIC_EVENTS_COUNT]); vd_printf(Connected to server); while (_running) { @@ -313,7 +313,7 @@ bool VDAgent::run() void VDAgent::cleanup() { CloseHandle(_control_event); - delete _vdi_port
[Spice-devel] [PATCH] vdagent: when SetClipboardData fails, set clipboard control event to stop wait
Currently, a SetClipboardData failure is followed by useless wait for timeout (VD_CLIPBOARD_TIMEOUT_MS) --- vdagent/vdagent.cpp | 30 -- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 3f1053d..2bb466d 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -643,12 +643,10 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size) if (_clipboard_owner != owner_client) { vd_printf(Received clipboard data from client while clipboard is not owned by client); -set_control_event(CONTROL_CLIPBOARD); -return false; +goto fin; } if (clipboard-type == VD_AGENT_CLIPBOARD_NONE) { -set_control_event(CONTROL_CLIPBOARD); -return false; +goto fin; } switch (clipboard-type) { case VD_AGENT_CLIPBOARD_UTF8_TEXT: @@ -664,20 +662,24 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size) } default: vd_printf(Unsupported clipboard type %u, clipboard-type); -return true; +goto fin; } format = get_clipboard_format(clipboard-type); -if (SetClipboardData(format, clip_data)) { -set_control_event(CONTROL_CLIPBOARD); -return true; -} -// We retry clipboard open-empty-set-close only when there is a timeout in on_clipboard_request() -if (!OpenClipboard(_hwnd)) { -return false; +if (format == 0) { +vd_printf(Unknown clipboard format, type %u, clipboard-type); +goto fin; } -EmptyClipboard(); ret = !!SetClipboardData(format, clip_data); -CloseClipboard(); +if (!ret) { +DWORD err = GetLastError(); +if (err == ERROR_NOT_ENOUGH_MEMORY) { +vd_printf(Not enough memory to set clipboard data, size %u bytes, size); +} else { +vd_printf(SetClipboardData failed: %u, err); +} +} +fin: +set_control_event(CONTROL_CLIPBOARD); return ret; } -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 1/3] vdagent: remove vdi_port, use vio_serial directly
--- vdagent/vdagent.cpp | 239 +++ 1 files changed, 109 insertions(+), 130 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 2bb466d..85244c0 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -16,8 +16,6 @@ */ #include vdcommon.h -#include virtio_vdi_port.h -#include pci_vdi_port.h #include desktop_layout.h #include display_setting.h #include ximage.h @@ -65,11 +63,7 @@ typedef struct ALIGN_VC VDIChunk { } ALIGN_GCC VDIChunk; #define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage)) - -enum { -VD_EVENT_CONTROL = 0, -VD_STATIC_EVENTS_COUNT // Must be last -}; +#define VD_READ_BUF_SIZE (sizeof(VDIChunk) + VD_AGENT_MAX_DATA_SIZE) class VDAgent { public: @@ -90,8 +84,6 @@ private: bool handle_clipboard_request(VDAgentClipboardRequest* clipboard_request); void handle_clipboard_release(); bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port); -void handle_port_in(); -void handle_port_out(); void handle_chunk(VDIChunk* chunk); void on_clipboard_grab(); void on_clipboard_request(UINT format); @@ -101,7 +93,9 @@ private: static HGLOBAL utf8_alloc(LPCSTR data, int size); static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); static DWORD WINAPI event_thread_proc(LPVOID param); -static void dispatch_message(VDAgentMessage* msg, uint32_t port); +static VOID CALLBACK read_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); +static VOID CALLBACK write_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); +void dispatch_message(VDAgentMessage* msg, uint32_t port); uint32_t get_clipboard_format(uint32_t type); uint32_t get_clipboard_type(uint32_t format); DWORD get_cximage_format(uint32_t type); @@ -114,7 +108,7 @@ private: void enqueue_chunk(VDIChunk* msg); bool write_message(uint32_t type, uint32_t size, void* data); bool write_clipboard(VDAgentMessage* msg, uint32_t size); -bool init_vdi_port(); +bool init_vio_serial(); bool send_input(); void set_display_depth(uint32_t depth); void load_display_setting(); @@ -134,16 +128,19 @@ private: INPUT _input; DWORD _input_time; HANDLE _control_event; -HANDLE* _events; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; -uint32_t _events_count; bool _pending_input; bool _running; bool _desktop_switch; DesktopLayout* _desktop_layout; DisplaySetting _display_setting; -VDIPort* _vdi_port; +HANDLE _vio_serial; +OVERLAPPED _read_overlapped; +OVERLAPPED _write_overlapped; +CHAR _read_buf[VD_READ_BUF_SIZE]; +DWORD _read_pos; +DWORD _write_pos; mutex_t _control_mutex; mutex_t _message_mutex; std::queueint _control_queue; @@ -163,6 +160,8 @@ private: VDAgent* VDAgent::_singleton = NULL; +#define VIOSERIAL_PORT_PATH L.\\Global\\com.redhat.spice.0 + VDAgent* VDAgent::get() { if (!_singleton) { @@ -181,16 +180,16 @@ VDAgent::VDAgent() , _mouse_y (0) , _input_time (0) , _control_event (NULL) -, _events (NULL) , _in_msg (NULL) , _in_msg_pos (0) -, _events_count (0) , _pending_input (false) , _running (false) , _desktop_switch (false) , _desktop_layout (NULL) , _display_setting (VD_AGENT_REGISTRY_KEY) -, _vdi_port (NULL) +, _vio_serial (NULL) +, _read_pos (0) +, _write_pos (0) , _logon_desktop (false) , _display_setting_initialized (false) , _client_caps (NULL) @@ -204,7 +203,10 @@ VDAgent::VDAgent() swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path); _log = VDLog::get(log_path); } -ZeroMemory(_input, sizeof(INPUT)); +ZeroMemory(_input, sizeof(_input)); +ZeroMemory(_read_overlapped, sizeof(_read_overlapped)); +ZeroMemory(_write_overlapped, sizeof(_write_overlapped)); +ZeroMemory(_read_buf, sizeof(_read_buf)); MUTEX_INIT(_control_mutex); MUTEX_INIT(_message_mutex); @@ -213,7 +215,6 @@ VDAgent::VDAgent() VDAgent::~VDAgent() { -delete _events; delete _log; delete[] _client_caps; } @@ -277,8 +278,13 @@ bool VDAgent::run() if (_desktop_layout-get_display_count() == 0) { vd_printf(No QXL devices!); } -if (!init_vdi_port()) { -vd_printf(Failed to create VDIPort instance); +if (!init_vio_serial()) { +cleanup(); +return false; +} +if (!ReadFileEx(_vio_serial, _read_buf, sizeof(VDIChunk), _read_overlapped, read_completion) +GetLastError() != ERROR_IO_PENDING) { +vd_printf(vio_serial read error %lu, GetLastError()); cleanup(); return false; } @@ -290,12 +296,6 @@ bool VDAgent::run() return false; } send_announce_capabilities(true); - -_events_count =
[Spice-devel] [PATCH 2/3] vdagent: remove vdi_port from vcproj
--- vdagent/vdagent.vcproj | 24 1 files changed, 0 insertions(+), 24 deletions(-) diff --git a/vdagent/vdagent.vcproj b/vdagent/vdagent.vcproj index b99297e..5e7bb43 100644 --- a/vdagent/vdagent.vcproj +++ b/vdagent/vdagent.vcproj @@ -350,25 +350,13 @@ /File File - RelativePath=.\pci_vdi_port.cpp - - /File - File RelativePath=.\vdagent.cpp /File File - RelativePath=.\vdi_port.cpp - - /File - File RelativePath=..\common\vdlog.cpp /File - File - RelativePath=.\virtio_vdi_port.cpp - - /File /Filter Filter Name=Header Files @@ -384,10 +372,6 @@ /File File - RelativePath=.\pci_vdi_port.h - - /File - File RelativePath=.\resource.h /File @@ -396,17 +380,9 @@ /File File - RelativePath=.\vdi_port.h - - /File - File RelativePath=..\common\vdlog.h /File - File - RelativePath=.\virtio_vdi_port.h - - /File /Filter Filter Name=Resource Files -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 3/3] vdagent: git rm *vdi_port*
--- vdagent/pci_vdi_port.cpp| 132 -- vdagent/pci_vdi_port.h | 59 -- vdagent/vdi_port.cpp| 90 - vdagent/vdi_port.h | 75 - vdagent/virtio_vdi_port.cpp | 187 --- vdagent/virtio_vdi_port.h | 33 6 files changed, 0 insertions(+), 576 deletions(-) delete mode 100644 vdagent/pci_vdi_port.cpp delete mode 100644 vdagent/pci_vdi_port.h delete mode 100644 vdagent/vdi_port.cpp delete mode 100644 vdagent/vdi_port.h delete mode 100644 vdagent/virtio_vdi_port.cpp delete mode 100644 vdagent/virtio_vdi_port.h diff --git a/vdagent/pci_vdi_port.cpp b/vdagent/pci_vdi_port.cpp deleted file mode 100644 index 7466fbc..000 --- a/vdagent/pci_vdi_port.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2009 Red Hat, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see http://www.gnu.org/licenses/. -*/ - -#include stdio.h -#include pci_vdi_port.h -#include vdlog.h - -#define VDI_PORT_DEV_NAME TEXT(.\\VDIPort) -#define FILE_DEVICE_UNKNOWN 0x0022 -#define METHOD_BUFFERED 0 -#define FILE_ANY_ACCESS 0 - -#ifndef CTL_CODE -//With mingw, this is defined in winioctl.h -#define CTL_CODE(DeviceType, Function, Method, Access) ( \ -((DeviceType) 16) | ((Access) 14) | ((Function) 2) | (Method) \ -) -#endif - -#define FIRST_AVAIL_IO_FUNC 0x800 -#define RED_TUNNEL_CTL_FUNC FIRST_AVAIL_IO_FUNC - -#define IOCTL_RED_TUNNEL_SET_EVENT \ -CTL_CODE(FILE_DEVICE_UNKNOWN, RED_TUNNEL_CTL_FUNC, METHOD_BUFFERED, FILE_ANY_ACCESS) - -#define MIN(a, b) ((a) (b) ? (b) : (a)) - -PCIVDIPort::PCIVDIPort() -: _handle (INVALID_HANDLE_VALUE) -, _event (NULL) -{ -} - -PCIVDIPort::~PCIVDIPort() -{ -if (_handle != INVALID_HANDLE_VALUE) { -CloseHandle(_handle); -} -if (_event) { -CloseHandle(_event); -} -} - -void PCIVDIPort::fill_events(HANDLE* handles) { -handles[PCI_VDI_PORT_EVENT] = _event; -} - -bool PCIVDIPort::init() -{ -DWORD io_ret_len; -_handle = CreateFile(VDI_PORT_DEV_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, 0, NULL); -if (_handle == INVALID_HANDLE_VALUE) { -vd_printf(CreateFile() failed: %lu, GetLastError()); -return false; -} -_event = CreateEvent(NULL, FALSE, FALSE, NULL); -if (_event == NULL) { -vd_printf(CreateEvent() failed: %lu, GetLastError()); -return false; -} -if (!DeviceIoControl(_handle, IOCTL_RED_TUNNEL_SET_EVENT, _event, sizeof(_event), - NULL, 0, io_ret_len, NULL)) { -vd_printf(DeviceIoControl() failed: %lu, GetLastError()); -return false; -} -return true; -} - -int PCIVDIPort::write() -{ -int size; -int n; - -if (_write.start == _write.end) { -return 0; -} -if (_write.start _write.end) { -size = (int)(_write.end - _write.start); -} else { -size = (int)(_write.ring[BUF_SIZE] - _write.start); -} -if (!WriteFile(_handle, _write.start, size, (LPDWORD)n, NULL)) { -return handle_error(); -} -_write.start = _write.ring + (_write.start - _write.ring + n) % BUF_SIZE; -return n; -} - -int PCIVDIPort::read() -{ -int size; -int n; - -if ((_read.end - _read.ring + 1) % BUF_SIZE == _read.start - _read.ring) { -return 0; -} -if (_read.start == _read.end) { -_read.start = _read.end = _read.ring; -} -if (_read.start = _read.end) { -size = MIN(BUF_SIZE - 1, (int)(_read.ring[BUF_SIZE] - _read.end)); -} else { -size = (int)(_read.start - _read.end - 1); -} -if (!ReadFile(_handle, _read.end, size, (LPDWORD)n, NULL)) { -return handle_error(); -} -_read.end = _read.ring + (_read.end - _read.ring + n) % BUF_SIZE; -return n; -} - -bool PCIVDIPort::handle_event(int event) -{ -// do nothing - the event merely serves to wake us up, then we call read/write -// at VDService::execute start of while(_running) loop. -return true; -} diff --git a/vdagent/pci_vdi_port.h b/vdagent/pci_vdi_port.h deleted file mode 100644 index fcc76dc..000 --- a/vdagent/pci_vdi_port.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2009 Red Hat, Inc. - - This program is free software; you can redistribute it
Re: [Spice-devel] [PATCH 1/3] vdagent: remove vdi_port, use vio_serial directly
NACK, seems it needs some more testing Arnon Gilboa wrote: --- vdagent/vdagent.cpp | 239 +++ 1 files changed, 109 insertions(+), 130 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 2bb466d..85244c0 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -16,8 +16,6 @@ */ #include vdcommon.h -#include virtio_vdi_port.h -#include pci_vdi_port.h #include desktop_layout.h #include display_setting.h #include ximage.h @@ -65,11 +63,7 @@ typedef struct ALIGN_VC VDIChunk { } ALIGN_GCC VDIChunk; #define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage)) - -enum { -VD_EVENT_CONTROL = 0, -VD_STATIC_EVENTS_COUNT // Must be last -}; +#define VD_READ_BUF_SIZE (sizeof(VDIChunk) + VD_AGENT_MAX_DATA_SIZE) class VDAgent { public: @@ -90,8 +84,6 @@ private: bool handle_clipboard_request(VDAgentClipboardRequest* clipboard_request); void handle_clipboard_release(); bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port); -void handle_port_in(); -void handle_port_out(); void handle_chunk(VDIChunk* chunk); void on_clipboard_grab(); void on_clipboard_request(UINT format); @@ -101,7 +93,9 @@ private: static HGLOBAL utf8_alloc(LPCSTR data, int size); static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); static DWORD WINAPI event_thread_proc(LPVOID param); -static void dispatch_message(VDAgentMessage* msg, uint32_t port); +static VOID CALLBACK read_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); +static VOID CALLBACK write_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlapped); +void dispatch_message(VDAgentMessage* msg, uint32_t port); uint32_t get_clipboard_format(uint32_t type); uint32_t get_clipboard_type(uint32_t format); DWORD get_cximage_format(uint32_t type); @@ -114,7 +108,7 @@ private: void enqueue_chunk(VDIChunk* msg); bool write_message(uint32_t type, uint32_t size, void* data); bool write_clipboard(VDAgentMessage* msg, uint32_t size); -bool init_vdi_port(); +bool init_vio_serial(); bool send_input(); void set_display_depth(uint32_t depth); void load_display_setting(); @@ -134,16 +128,19 @@ private: INPUT _input; DWORD _input_time; HANDLE _control_event; -HANDLE* _events; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; -uint32_t _events_count; bool _pending_input; bool _running; bool _desktop_switch; DesktopLayout* _desktop_layout; DisplaySetting _display_setting; -VDIPort* _vdi_port; +HANDLE _vio_serial; +OVERLAPPED _read_overlapped; +OVERLAPPED _write_overlapped; +CHAR _read_buf[VD_READ_BUF_SIZE]; +DWORD _read_pos; +DWORD _write_pos; mutex_t _control_mutex; mutex_t _message_mutex; std::queueint _control_queue; @@ -163,6 +160,8 @@ private: VDAgent* VDAgent::_singleton = NULL; +#define VIOSERIAL_PORT_PATH L.\\Global\\com.redhat.spice.0 + VDAgent* VDAgent::get() { if (!_singleton) { @@ -181,16 +180,16 @@ VDAgent::VDAgent() , _mouse_y (0) , _input_time (0) , _control_event (NULL) -, _events (NULL) , _in_msg (NULL) , _in_msg_pos (0) -, _events_count (0) , _pending_input (false) , _running (false) , _desktop_switch (false) , _desktop_layout (NULL) , _display_setting (VD_AGENT_REGISTRY_KEY) -, _vdi_port (NULL) +, _vio_serial (NULL) +, _read_pos (0) +, _write_pos (0) , _logon_desktop (false) , _display_setting_initialized (false) , _client_caps (NULL) @@ -204,7 +203,10 @@ VDAgent::VDAgent() swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path); _log = VDLog::get(log_path); } -ZeroMemory(_input, sizeof(INPUT)); +ZeroMemory(_input, sizeof(_input)); +ZeroMemory(_read_overlapped, sizeof(_read_overlapped)); +ZeroMemory(_write_overlapped, sizeof(_write_overlapped)); +ZeroMemory(_read_buf, sizeof(_read_buf)); MUTEX_INIT(_control_mutex); MUTEX_INIT(_message_mutex); @@ -213,7 +215,6 @@ VDAgent::VDAgent() VDAgent::~VDAgent() { -delete _events; delete _log; delete[] _client_caps; } @@ -277,8 +278,13 @@ bool VDAgent::run() if (_desktop_layout-get_display_count() == 0) { vd_printf(No QXL devices!); } -if (!init_vdi_port()) { -vd_printf(Failed to create VDIPort instance); +if (!init_vio_serial()) { +cleanup(); +return false; +} +if (!ReadFileEx(_vio_serial, _read_buf, sizeof(VDIChunk), _read_overlapped, read_completion) +GetLastError() != ERROR_IO_PENDING) { +vd_printf(vio_serial read error %lu, GetLastError()); cleanup(); return false; } @@ -290,12 +296,6 @@ bool VDAgent::run() return false
[Spice-devel] [PATCH] vdservice: support Windows 8 Server 2012
vdagent was ok, but vdservice required adding these to the version check. Both are handled as the rest of the Win7 class. Tested on Win8x64. --- vdservice/vdservice.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 8f12317..b64602b 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -121,7 +121,7 @@ VDService* VDService::get() enum SystemVersion { SYS_VER_UNSUPPORTED, SYS_VER_WIN_XP_CLASS, // also Server 2003/R2 -SYS_VER_WIN_7_CLASS, // also Server 2008/R2 Vista +SYS_VER_WIN_7_CLASS, // also Windows 8, Server 2012, Server 2008/R2 Vista }; int supported_system_version() @@ -136,7 +136,7 @@ int supported_system_version() } if (osvi.dwMajorVersion == 5 (osvi.dwMinorVersion == 1 || osvi.dwMinorVersion == 2)) { return SYS_VER_WIN_XP_CLASS; -} else if (osvi.dwMajorVersion == 6 (osvi.dwMinorVersion == 0 || osvi.dwMinorVersion == 1)) { +} else if (osvi.dwMajorVersion == 6 (osvi.dwMinorVersion = 0 || osvi.dwMinorVersion = 2)) { return SYS_VER_WIN_7_CLASS; } return 0; -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Guest agent for Windows 8
Erik Lotspeich wrote: On 11/21/2012 07:13 AM, Christophe Fergeau wrote: On Wed, Nov 21, 2012 at 02:59:44PM +0200, Arnon Gilboa wrote: Christophe Fergeau wrote: On Tue, Nov 20, 2012 at 11:34:56AM -0600, Erik Lotspeich wrote: I was wondering if there will be a Windows 8 build for the Windows guest tools soon. I don't have much experience with Windows development or how to compile the source. Is this something that is fairly easy to do? Can Cygwin be used, or is Visual Studio required? What's wrong exactly with the current tools? The version checks that fails I guess? I guess so. 'll check it and patch accordingly. Ah, I was thinking of a version check I have in spice-guest-tools.exe, not in the agent ;) Christophe Correct. The EXE says unknown windows version. It seems like Windows 7 drivers/apps generally work on Windows 8 so maybe this is the only issue. Regards Erik Patched, Arnon From ed1fe65b8409c6d336b4cc46cfeb2e3a4152b56a Mon Sep 17 00:00:00 2001 From: Arnon Gilboa agil...@redhat.com Date: Thu, 22 Nov 2012 13:15:02 +0200 Subject: [PATCH] vdservice: support Windows 8 Server 2012 vdagent was ok, but vdservice required adding these to the version check. Both are handled as the rest of the Win7 class. Tested on Win8x64. --- vdservice/vdservice.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 8f12317..b64602b 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -121,7 +121,7 @@ VDService* VDService::get() enum SystemVersion { SYS_VER_UNSUPPORTED, SYS_VER_WIN_XP_CLASS, // also Server 2003/R2 -SYS_VER_WIN_7_CLASS, // also Server 2008/R2 Vista +SYS_VER_WIN_7_CLASS, // also Windows 8, Server 2012, Server 2008/R2 Vista }; int supported_system_version() @@ -136,7 +136,7 @@ int supported_system_version() } if (osvi.dwMajorVersion == 5 (osvi.dwMinorVersion == 1 || osvi.dwMinorVersion == 2)) { return SYS_VER_WIN_XP_CLASS; -} else if (osvi.dwMajorVersion == 6 (osvi.dwMinorVersion == 0 || osvi.dwMinorVersion == 1)) { +} else if (osvi.dwMajorVersion == 6 (osvi.dwMinorVersion = 0 || osvi.dwMinorVersion = 2)) { return SYS_VER_WIN_7_CLASS; } return 0; -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Guest agent for Windows 8
Arnon Gilboa wrote: Erik Lotspeich wrote: On 11/21/2012 07:13 AM, Christophe Fergeau wrote: On Wed, Nov 21, 2012 at 02:59:44PM +0200, Arnon Gilboa wrote: Christophe Fergeau wrote: On Tue, Nov 20, 2012 at 11:34:56AM -0600, Erik Lotspeich wrote: I was wondering if there will be a Windows 8 build for the Windows guest tools soon. I don't have much experience with Windows development or how to compile the source. Is this something that is fairly easy to do? Can Cygwin be used, or is Visual Studio required? What's wrong exactly with the current tools? The version checks that fails I guess? I guess so. 'll check it and patch accordingly. Ah, I was thinking of a version check I have in spice-guest-tools.exe, not in the agent ;) Christophe Correct. The EXE says unknown windows version. It seems like Windows 7 drivers/apps generally work on Windows 8 so maybe this is the only issue. Regards Erik Patched, Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel fixed patch on the list ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Guest agent for Windows 8
Christophe Fergeau wrote: Hey, On Tue, Nov 20, 2012 at 11:34:56AM -0600, Erik Lotspeich wrote: I was wondering if there will be a Windows 8 build for the Windows guest tools soon. I don't have much experience with Windows development or how to compile the source. Is this something that is fairly easy to do? Can Cygwin be used, or is Visual Studio required? What's wrong exactly with the current tools? The version checks that fails I guess? Christophe I guess so. 'll check it and patch accordingly. Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [vdagent-win] mingw: Don't define OLDMSCVRT for mingw builds
Christophe Fergeau wrote: On Mon, Nov 19, 2012 at 08:33:36AM -0500, Marc-André Lureau wrote: - Mensaje original - When it's defined, this causes some fallback code to be used. In particular, this causes log messages to not get timestamps. Issue reported by Han Pilmeyer. You can also try to implement timing with old/default msvcrt, but I wouldn't bother going in that direction. Depends on the amount of work, could be just a few lines of code. Ie, do we require a newer MSVCRT and keep doing logging the wrong way, or do we use default MSVCRT and switch to a proper logging. I don't think the timestamp are really wanted here anyway (why is it needed in the first place?), and people who need it can compile the agent without OLDMSVCRT or with MSVC. Depends how new is the newer MSVCRT. If it's present in winxp sp3 and newer, we should be good. agree I assume MSVCRT is always dynamically linked? statically linked with msvcrt.lib which uses msvcrX.dll at runtime mingw-vdagent uses -static when building, and built successfully with this change. nice How does this work with MSVC++ builds by the way? Do they statically link with the newer msvcrt version? using static RTL, libcmt.lib (/MT compiler flag) Regarding timestamps in logs, they are useful to know how recent a log is, ie can the issue I just got be related to this weird log line, or has this log been present in the file for days now? see rhbz #672828 Christophe ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [vdagent-win] Fix mingw compilation
ack Christophe Fergeau wrote: This got broken with the recent code moves from vdservice to vdagent. --- Makefile.am | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index b050aff..9b73def 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,7 +20,7 @@ LIBS = -lversion bin_PROGRAMS = vdagent vdservice -vdagent_LDADD = $(CXIMAGE_LIBS) vdagent_rc.$(OBJEXT) +vdagent_LDADD = -lwtsapi32 $(CXIMAGE_LIBS) vdagent_rc.$(OBJEXT) vdagent_CXXFLAGS = $(AM_CXXFLAGS) $(CXIMAGE_CFLAGS) vdagent_LDFLAGS = $(AM_LDFLAGS) -Wl,--subsystem,windows vdagent_SOURCES = \ @@ -31,7 +31,13 @@ vdagent_SOURCES =\ vdagent/desktop_layout.h\ vdagent/display_setting.cpp \ vdagent/display_setting.h \ + vdagent/pci_vdi_port.cpp\ + vdagent/pci_vdi_port.h \ vdagent/vdagent.cpp \ + vdagent/vdi_port.cpp\ + vdagent/vdi_port.h \ + vdagent/virtio_vdi_port.cpp \ + vdagent/virtio_vdi_port.h \ $(NULL) vdagent_rc.$(OBJEXT): vdagent/vdagent.rc @@ -45,13 +51,7 @@ vdservice_SOURCES = \ common/vdcommon.h \ common/vdlog.cpp\ common/vdlog.h \ - vdservice/pci_vdi_port.cpp \ - vdservice/pci_vdi_port.h\ - vdservice/vdi_port.cpp \ - vdservice/vdi_port.h\ vdservice/vdservice.cpp \ - vdservice/virtio_vdi_port.cpp \ - vdservice/virtio_vdi_port.h \ $(NULL) vdservice_rc.$(OBJEXT): vdservice/vdservice.rc ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH 5/5] vdagent: extract event_dispatcher from input_desktop_message_loop
Christophe Fergeau wrote: On Wed, Nov 07, 2012 at 03:19:51PM +0200, Arnon Gilboa wrote: --- vdagent/vdagent.cpp | 105 +++ 1 files changed, 56 insertions(+), 49 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 9bb0898..7495826 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -80,6 +80,7 @@ public: private: VDAgent(); void input_desktop_message_loop(); +void event_dispatcher(DWORD timeout, DWORD wake_mask); bool handle_mouse_event(VDAgentMouseState* state); bool handle_announce_capabilities(VDAgentAnnounceCapabilities* announce_capabilities, uint32_t msg_size); @@ -362,9 +363,7 @@ void VDAgent::handle_control_event() void VDAgent::input_desktop_message_loop() { TCHAR desktop_name[MAX_PATH]; -DWORD wait_ret; HDESK hdesk; -MSG msg; hdesk = OpenInputDesktop(0, FALSE, GENERIC_ALL); if (!hdesk) { @@ -412,53 +411,7 @@ void VDAgent::input_desktop_message_loop() } _hwnd_next_viewer = SetClipboardViewer(_hwnd); while (_running !_desktop_switch) { -int cont_read = _vdi_port-read(); -int cont_write = _vdi_port-write(); -bool cont = false; - -if (cont_read = 0 cont_write = 0) { -cont = cont_read || cont_write; -} else if (cont_read == VDI_PORT_ERROR || cont_write == VDI_PORT_ERROR) { -vd_printf(VDI Port error, read %d write %d, cont_read, cont_write); -_running = false; -break; -} else if (cont_read == VDI_PORT_RESET || cont_write == VDI_PORT_RESET) { -vd_printf(VDI Port reset, read %d write %d, cont_read, cont_write); -_running = false; -break; -} -if (cont_read) { -handle_port_in(); -} -if (cont_write) { -handle_port_out(); -} - -wait_ret = MsgWaitForMultipleObjectsEx(_events_count, _events, cont ? 0 : INFINITE, - QS_ALLINPUT, MWMO_ALERTABLE); -if (wait_ret == WAIT_OBJECT_0 + _events_count) { -while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { -TranslateMessage(msg); -DispatchMessage(msg); -} -continue; -} -switch (wait_ret) { -case WAIT_OBJECT_0 + VD_EVENT_CONTROL: -handle_control_event(); -break; -case WAIT_IO_COMPLETION: -case WAIT_TIMEOUT: -break; -default: -DWORD vdi_event = wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0; -if (vdi_event = 0 vdi_event _vdi_port-get_num_events()) { -_running = _vdi_port-handle_event(vdi_event); -} else { -vd_printf(MsgWaitForMultipleObjectsEx failed: %lu %lu, wait_ret, GetLastError()); -_running = false; -} -} +event_dispatcher(INFINITE, QS_ALLINPUT); } _desktop_switch = false; if (_pending_input) { @@ -471,6 +424,60 @@ void VDAgent::input_desktop_message_loop() CloseDesktop(hdesk); } +void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask) +{ +DWORD wait_ret; +MSG msg; + +int cont_read = _vdi_port-read(); +int cont_write = _vdi_port-write(); +bool cont = false; + +if (cont_read = 0 cont_write = 0) { +cont = cont_read || cont_write; +} else if (cont_read == VDI_PORT_ERROR || cont_write == VDI_PORT_ERROR) { +vd_printf(VDI Port error, read %d write %d, cont_read, cont_write); +_running = false; +return; +} else if (cont_read == VDI_PORT_RESET || cont_write == VDI_PORT_RESET) { +vd_printf(VDI Port reset, read %d write %d, cont_read, cont_write); +_running = false; +return; +} +if (cont_read) { +handle_port_in(); +} +if (cont_write) { +handle_port_out(); +} + +wait_ret = MsgWaitForMultipleObjects(_events_count, _events, FALSE, cont ? 0 : timeout, + wake_mask); This is not a simple move as this used to be MsgWaitForMultipleObjectsEx and .. + +if (wake_mask wait_ret == WAIT_OBJECT_0 + _events_count) { +while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { +TranslateMessage(msg); +DispatchMessage(msg); +} +return; +} +switch (wait_ret) { +case WAIT_OBJECT_0 + VD_EVENT_CONTROL: +handle_control_event(); +break; +case WAIT_TIMEOUT: ... there used to have a WAIT_IO_COMPLETION case. I assume they are no longer needed after the removal of the pipe, but this would have been better in a separate commit (ie code movement in one, those changes in another). right. the Ex() WAIT_IO_COMPLETION are no longer needed as we don't use the pipe read/write completion routines
Re: [Spice-devel] [PATCH 3/5] vdagent: use virtio-serial, remove pipe usage
Christophe Fergeau wrote: This one is quite complicated to review, I didn't look at it very carefully... will be nice if you give it another 5 mins... On Wed, Nov 07, 2012 at 03:19:49PM +0200, Arnon Gilboa wrote: --- vdagent/vdagent.cpp| 467 +++- vdagent/vdagent.vcproj | 32 +++- 2 files changed, 256 insertions(+), 243 deletions(-) +void VDAgent::handle_port_out() +{ +MUTEX_LOCK(_message_mutex); +while (_running !_message_queue.empty()) { +VDIChunk* chunk = _message_queue.front(); +DWORD size = sizeof(VDIChunk) + chunk-hdr.size; -if (size size_left) { +if (size _vdi_port-write_ring_free_space()) { break; } -a-_message_queue.pop(); -memcpy(a-_pipe_state.write.data + a-_pipe_state.write.end, msg, size); -a-_pipe_state.write.end += size; -size_left -= size; -delete msg; -} -MUTEX_UNLOCK(a-_message_mutex); - -if (ps-write.start ps-write.end) { -if (WriteFileEx(ps-pipe, ps-write.data + ps-write.start, - ps-write.end - ps-write.start, overlap, write_completion)) { -a-_pending_write = true; -} else { -vd_printf(WriteFileEx() failed: %lu, GetLastError()); -a-_running = false; +_message_queue.pop(); +if (_vdi_port-ring_write(chunk, size) != size) { +vd_printf(ring_write failed); +_running = false; +return; This looks like this will be leaking 'chunk'. Christophe 10x, although we exit in this case i have no idea where did that return came from ;) } -} else { -a-_pending_write = false; +delete chunk; } -MUTEX_UNLOCK(a-_write_mutex); +MUTEX_UNLOCK(_message_mutex); } ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH 0/5] move vio-serial use to vdagent, remove named pipe
Christophe Fergeau wrote: On Wed, Nov 07, 2012 at 03:19:46PM +0200, Arnon Gilboa wrote: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run seperately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug No permissions issues wrt user privileges when an unpriviledged windows user tries to use virtio-serial? I'm assuming the agent will run the windows user that is logged in. When vdservice starts vdagent, it runs as SYSTEM. To manually run (new) vdagent, you need to do run it as admin. Otherwise it will exit immediately, failing to open vio-serial. Christophe cons: -when switching between users client will switch to server mode for a few ms Arnon Gilboa (5): vdservice: remove virtio-serial pipe usage vdagent: mv vdi_port files from vdservice vdagent: use virtio-serial, remove pipe usage vdagent: remove pipe common defs vdagent: extract event_dispatcher from input_desktop_message_loop common/vdcommon.h | 31 --- vdagent/pci_vdi_port.cpp | 132 +++ vdagent/pci_vdi_port.h| 59 + vdagent/vdagent.cpp | 498 - vdagent/vdagent.vcproj| 32 +++- vdagent/vdi_port.cpp | 90 vdagent/vdi_port.h| 75 ++ vdagent/virtio_vdi_port.cpp | 187 +++ vdagent/virtio_vdi_port.h | 33 +++ vdservice/pci_vdi_port.cpp| 132 --- vdservice/pci_vdi_port.h | 59 - vdservice/vdi_port.cpp| 90 vdservice/vdi_port.h | 75 -- vdservice/vdservice.cpp | 471 +++--- vdservice/vdservice.vcproj| 24 -- vdservice/virtio_vdi_port.cpp | 187 --- vdservice/virtio_vdi_port.h | 33 --- 17 files changed, 887 insertions(+), 1321 deletions(-) create mode 100644 vdagent/pci_vdi_port.cpp create mode 100644 vdagent/pci_vdi_port.h create mode 100644 vdagent/vdi_port.cpp create mode 100644 vdagent/vdi_port.h create mode 100644 vdagent/virtio_vdi_port.cpp create mode 100644 vdagent/virtio_vdi_port.h delete mode 100644 vdservice/pci_vdi_port.cpp delete mode 100644 vdservice/pci_vdi_port.h delete mode 100644 vdservice/vdi_port.cpp delete mode 100644 vdservice/vdi_port.h delete mode 100644 vdservice/virtio_vdi_port.cpp delete mode 100644 vdservice/virtio_vdi_port.h -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] RFC: vdagent-win and virtio-serial
Itamar Heim wrote: On 10/18/2012 12:26 PM, Arnon Gilboa wrote: Hi, I'd like to make a small change in vdagent-win: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run separately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug Comments anyone? how would backward compatibility or upgrade path look like? nothing changed with regards to backward compatibility and upgrade path. it's only an internal implementation issue. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH 0/5] move vio-serial use to vdagent, remove named pipe
Alon Levy wrote: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run seperately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug cons: -when switching between users client will switch to server mode for a few ms hmm, we can add another separate virtio device just for the purpose of saying guest is agent aware, and have that opened (and nothing written to it) by the service. com.redhat.spice.alive not sure it worth that. the switch is quite negligible. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 0/5] move vio-serial use to vdagent, remove named pipe
-move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run seperately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug cons: -when switching between users client will switch to server mode for a few ms Arnon Gilboa (5): vdservice: remove virtio-serial pipe usage vdagent: mv vdi_port files from vdservice vdagent: use virtio-serial, remove pipe usage vdagent: remove pipe common defs vdagent: extract event_dispatcher from input_desktop_message_loop common/vdcommon.h | 31 --- vdagent/pci_vdi_port.cpp | 132 +++ vdagent/pci_vdi_port.h| 59 + vdagent/vdagent.cpp | 498 - vdagent/vdagent.vcproj| 32 +++- vdagent/vdi_port.cpp | 90 vdagent/vdi_port.h| 75 ++ vdagent/virtio_vdi_port.cpp | 187 +++ vdagent/virtio_vdi_port.h | 33 +++ vdservice/pci_vdi_port.cpp| 132 --- vdservice/pci_vdi_port.h | 59 - vdservice/vdi_port.cpp| 90 vdservice/vdi_port.h | 75 -- vdservice/vdservice.cpp | 471 +++--- vdservice/vdservice.vcproj| 24 -- vdservice/virtio_vdi_port.cpp | 187 --- vdservice/virtio_vdi_port.h | 33 --- 17 files changed, 887 insertions(+), 1321 deletions(-) create mode 100644 vdagent/pci_vdi_port.cpp create mode 100644 vdagent/pci_vdi_port.h create mode 100644 vdagent/vdi_port.cpp create mode 100644 vdagent/vdi_port.h create mode 100644 vdagent/virtio_vdi_port.cpp create mode 100644 vdagent/virtio_vdi_port.h delete mode 100644 vdservice/pci_vdi_port.cpp delete mode 100644 vdservice/pci_vdi_port.h delete mode 100644 vdservice/vdi_port.cpp delete mode 100644 vdservice/vdi_port.h delete mode 100644 vdservice/virtio_vdi_port.cpp delete mode 100644 vdservice/virtio_vdi_port.h -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 1/5] vdservice: remove virtio-serial pipe usage
--- vdservice/vdservice.cpp| 471 vdservice/vdservice.vcproj | 24 --- 2 files changed, 36 insertions(+), 459 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 2b925fd..8f12317 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -18,13 +18,10 @@ #include windows.h #include winternl.h #include wtsapi32.h -#include userenv.h #include stdio.h #include tlhelp32.h #include queue #include vdcommon.h -#include virtio_vdi_port.h -#include pci_vdi_port.h //#define DEBUG_VDSERVICE @@ -45,21 +42,16 @@ // This enum simplifies WaitForMultipleEvents for static // events, that is handles that are guranteed non NULL. // It doesn't include: -// VirtioVDIPort Handles - these are filled by an interface because -// of variable handle number. // VDAgent handle - this can be 1 or 0 (NULL or not), so it is also added at // the end of VDService::_events enum { -VD_EVENT_PIPE_READ = 0, -VD_EVENT_PIPE_WRITE, -VD_EVENT_CONTROL, +VD_EVENT_CONTROL = 0, VD_STATIC_EVENTS_COUNT // Must be last }; enum { VD_CONTROL_IDLE = 0, VD_CONTROL_STOP, -VD_CONTROL_LOGON, VD_CONTROL_RESTART_AGENT, }; @@ -80,16 +72,8 @@ private: static DWORD WINAPI control_handler(DWORD control, DWORD event_type, LPVOID event_data, LPVOID context); static VOID WINAPI main(DWORD argc, TCHAR * argv[]); -bool init_vdi_port(); void set_control_event(int control_command); void handle_control_event(); -void pipe_write_completion(); -void pipe_read_completion(); -void write_agent_control(uint32_t type, uint32_t opaque); -void read_pipe(); -void handle_pipe_data(DWORD bytes); -void handle_port_data(); -bool handle_agent_control(VDPipeMessage* msg); bool restart_agent(bool normal_restart); bool launch_agent(); bool kill_agent(); @@ -110,22 +94,14 @@ private: HANDLE _control_event; HANDLE* _events; TCHAR _agent_path[MAX_PATH]; -VDIPort* _vdi_port; -VDPipeState _pipe_state; VDControlQueue _control_queue; mutex_t _control_mutex; mutex_t _agent_mutex; uint32_t _connection_id; DWORD _session_id; -DWORD _chunk_port; -DWORD _chunk_size; DWORD _last_agent_restart_time; int _agent_restarts; int _system_version; -bool _pipe_connected; -bool _pending_reset; -bool _pending_write; -bool _pending_read; bool _agent_alive; bool _running; VDLog* _log; @@ -169,28 +145,18 @@ int supported_system_version() VDService::VDService() : _status_handle (0) , _events (NULL) -, _vdi_port (NULL) , _connection_id (0) , _session_id (0) -, _chunk_port (0) -, _chunk_size (0) , _last_agent_restart_time (0) , _agent_restarts (0) -, _pipe_connected (false) -, _pending_reset (false) -, _pending_write (false) -, _pending_read (false) , _agent_alive (false) , _running (false) , _log (NULL) , _events_count(0) { ZeroMemory(_agent_proc_info, sizeof(_agent_proc_info)); -ZeroMemory(_pipe_state, sizeof(_pipe_state)); _system_version = supported_system_version(); _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); -_pipe_state.write.overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); -_pipe_state.read.overlap.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); _agent_path[0] = wchar_t('\0'); MUTEX_INIT(_agent_mutex); MUTEX_INIT(_control_mutex); @@ -199,8 +165,6 @@ VDService::VDService() VDService::~VDService() { -CloseHandle(_pipe_state.read.overlap.hEvent); -CloseHandle(_pipe_state.write.overlap.hEvent); CloseHandle(_control_event); delete _events; delete _log; @@ -320,14 +284,10 @@ void VDService::handle_control_event() while (_control_queue.size()) { int control_command = _control_queue.front(); _control_queue.pop(); -vd_printf(Control command %d, control_command); switch (control_command) { case VD_CONTROL_STOP: _running = false; break; -case VD_CONTROL_LOGON: -write_agent_control(VD_AGENT_SESSION_LOGON, 0); -break; case VD_CONTROL_RESTART_AGENT: _running = restart_agent(true); break; @@ -361,13 +321,9 @@ DWORD WINAPI VDService::control_handler(DWORD control, DWORD event_type, LPVOID DWORD session_id = ((WTSSESSION_NOTIFICATION*)event_data)-dwSessionId; vd_printf(Session %lu %s, session_id, session_events[event_type]); SetServiceStatus(s-_status_handle, s-_status); -if (s-_system_version != SYS_VER_UNSUPPORTED) { -if (event_type == WTS_CONSOLE_CONNECT) { -s-_session_id = session_id; -s-set_control_event(VD_CONTROL_RESTART_AGENT); -} else if (event_type ==
[Spice-devel] [PATCH 2/5] vdagent: mv vdi_port files from vdservice
--- vdagent/pci_vdi_port.cpp | 132 + vdagent/pci_vdi_port.h| 59 + vdagent/vdi_port.cpp | 90 vdagent/vdi_port.h| 75 vdagent/virtio_vdi_port.cpp | 187 + vdagent/virtio_vdi_port.h | 33 +++ vdservice/pci_vdi_port.cpp| 132 - vdservice/pci_vdi_port.h | 59 - vdservice/vdi_port.cpp| 90 vdservice/vdi_port.h | 75 vdservice/virtio_vdi_port.cpp | 187 - vdservice/virtio_vdi_port.h | 33 --- 12 files changed, 576 insertions(+), 576 deletions(-) create mode 100644 vdagent/pci_vdi_port.cpp create mode 100644 vdagent/pci_vdi_port.h create mode 100644 vdagent/vdi_port.cpp create mode 100644 vdagent/vdi_port.h create mode 100644 vdagent/virtio_vdi_port.cpp create mode 100644 vdagent/virtio_vdi_port.h delete mode 100644 vdservice/pci_vdi_port.cpp delete mode 100644 vdservice/pci_vdi_port.h delete mode 100644 vdservice/vdi_port.cpp delete mode 100644 vdservice/vdi_port.h delete mode 100644 vdservice/virtio_vdi_port.cpp delete mode 100644 vdservice/virtio_vdi_port.h diff --git a/vdagent/pci_vdi_port.cpp b/vdagent/pci_vdi_port.cpp new file mode 100644 index 000..7466fbc --- /dev/null +++ b/vdagent/pci_vdi_port.cpp @@ -0,0 +1,132 @@ +/* + Copyright (C) 2009 Red Hat, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/. +*/ + +#include stdio.h +#include pci_vdi_port.h +#include vdlog.h + +#define VDI_PORT_DEV_NAME TEXT(.\\VDIPort) +#define FILE_DEVICE_UNKNOWN 0x0022 +#define METHOD_BUFFERED 0 +#define FILE_ANY_ACCESS 0 + +#ifndef CTL_CODE +//With mingw, this is defined in winioctl.h +#define CTL_CODE(DeviceType, Function, Method, Access) ( \ +((DeviceType) 16) | ((Access) 14) | ((Function) 2) | (Method) \ +) +#endif + +#define FIRST_AVAIL_IO_FUNC 0x800 +#define RED_TUNNEL_CTL_FUNC FIRST_AVAIL_IO_FUNC + +#define IOCTL_RED_TUNNEL_SET_EVENT \ +CTL_CODE(FILE_DEVICE_UNKNOWN, RED_TUNNEL_CTL_FUNC, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define MIN(a, b) ((a) (b) ? (b) : (a)) + +PCIVDIPort::PCIVDIPort() +: _handle (INVALID_HANDLE_VALUE) +, _event (NULL) +{ +} + +PCIVDIPort::~PCIVDIPort() +{ +if (_handle != INVALID_HANDLE_VALUE) { +CloseHandle(_handle); +} +if (_event) { +CloseHandle(_event); +} +} + +void PCIVDIPort::fill_events(HANDLE* handles) { +handles[PCI_VDI_PORT_EVENT] = _event; +} + +bool PCIVDIPort::init() +{ +DWORD io_ret_len; +_handle = CreateFile(VDI_PORT_DEV_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, NULL); +if (_handle == INVALID_HANDLE_VALUE) { +vd_printf(CreateFile() failed: %lu, GetLastError()); +return false; +} +_event = CreateEvent(NULL, FALSE, FALSE, NULL); +if (_event == NULL) { +vd_printf(CreateEvent() failed: %lu, GetLastError()); +return false; +} +if (!DeviceIoControl(_handle, IOCTL_RED_TUNNEL_SET_EVENT, _event, sizeof(_event), + NULL, 0, io_ret_len, NULL)) { +vd_printf(DeviceIoControl() failed: %lu, GetLastError()); +return false; +} +return true; +} + +int PCIVDIPort::write() +{ +int size; +int n; + +if (_write.start == _write.end) { +return 0; +} +if (_write.start _write.end) { +size = (int)(_write.end - _write.start); +} else { +size = (int)(_write.ring[BUF_SIZE] - _write.start); +} +if (!WriteFile(_handle, _write.start, size, (LPDWORD)n, NULL)) { +return handle_error(); +} +_write.start = _write.ring + (_write.start - _write.ring + n) % BUF_SIZE; +return n; +} + +int PCIVDIPort::read() +{ +int size; +int n; + +if ((_read.end - _read.ring + 1) % BUF_SIZE == _read.start - _read.ring) { +return 0; +} +if (_read.start == _read.end) { +_read.start = _read.end = _read.ring; +} +if (_read.start = _read.end) { +size = MIN(BUF_SIZE - 1, (int)(_read.ring[BUF_SIZE] - _read.end)); +} else { +size = (int)(_read.start - _read.end - 1); +} +if (!ReadFile(_handle, _read.end, size,
[Spice-devel] [PATCH 3/5] vdagent: use virtio-serial, remove pipe usage
--- vdagent/vdagent.cpp| 467 +++- vdagent/vdagent.vcproj | 32 +++- 2 files changed, 256 insertions(+), 243 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 078e50f..9bb0898 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -16,11 +16,14 @@ */ #include vdcommon.h +#include virtio_vdi_port.h +#include pci_vdi_port.h #include desktop_layout.h #include display_setting.h #include ximage.h #undef max #undef min +#include wtsapi32.h #include lmcons.h #include queue #include set @@ -56,6 +59,18 @@ static ImageType image_types[] = { {VD_AGENT_CLIPBOARD_IMAGE_BMP, CXIMAGE_FORMAT_BMP}, }; +typedef struct ALIGN_VC VDIChunk { +VDIChunkHeader hdr; +uint8_t data[0]; +} ALIGN_GCC VDIChunk; + +#define VD_MESSAGE_HEADER_SIZE (sizeof(VDIChunk) + sizeof(VDAgentMessage)) + +enum { +VD_EVENT_CONTROL = 0, +VD_STATIC_EVENTS_COUNT // Must be last +}; + class VDAgent { public: static VDAgent* get(); @@ -74,7 +89,9 @@ private: bool handle_clipboard_request(VDAgentClipboardRequest* clipboard_request); void handle_clipboard_release(); bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port); -bool handle_control(VDPipeMessage* msg); +void handle_port_in(); +void handle_port_out(); +void handle_chunk(VDIChunk* chunk); void on_clipboard_grab(); void on_clipboard_request(UINT format); void on_clipboard_release(); @@ -82,8 +99,6 @@ private: DWORD mask, DWORD down_flag, DWORD up_flag); static HGLOBAL utf8_alloc(LPCSTR data, int size); static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -static VOID CALLBACK read_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlap); -static VOID CALLBACK write_completion(DWORD err, DWORD bytes, LPOVERLAPPED overlap); static DWORD WINAPI event_thread_proc(LPVOID param); static void dispatch_message(VDAgentMessage* msg, uint32_t port); uint32_t get_clipboard_format(uint32_t type); @@ -91,14 +106,14 @@ private: DWORD get_cximage_format(uint32_t type); enum { owner_none, owner_guest, owner_client }; void set_clipboard_owner(int new_owner); -enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH }; +enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON }; void set_control_event(int control_command); void handle_control_event(); -VDPipeMessage* new_message(DWORD bytes = 0); -void enqueue_message(VDPipeMessage* msg); +VDIChunk* new_chunk(DWORD bytes = 0); +void enqueue_chunk(VDIChunk* msg); bool write_message(uint32_t type, uint32_t size, void* data); bool write_clipboard(VDAgentMessage* msg, uint32_t size); -bool connect_pipe(); +bool init_vdi_port(); bool send_input(); void set_display_depth(uint32_t depth); void load_display_setting(); @@ -117,20 +132,20 @@ private: DWORD _input_time; HANDLE _control_event; HANDLE _clipboard_event; +HANDLE* _events; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; +uint32_t _events_count; bool _pending_input; -bool _pending_write; bool _running; bool _desktop_switch; DesktopLayout* _desktop_layout; DisplaySetting _display_setting; -VDPipeState _pipe_state; -mutex_t _write_mutex; +VDIPort* _vdi_port; mutex_t _control_mutex; mutex_t _message_mutex; std::queueint _control_queue; -std::queueVDPipeMessage* _message_queue; +std::queueVDIChunk* _message_queue; bool _logon_desktop; bool _display_setting_initialized; @@ -164,14 +179,16 @@ VDAgent::VDAgent() , _input_time (0) , _control_event (NULL) , _clipboard_event (NULL) +, _events (NULL) , _in_msg (NULL) , _in_msg_pos (0) +, _events_count (0) , _pending_input (false) -, _pending_write (false) , _running (false) , _desktop_switch (false) , _desktop_layout (NULL) , _display_setting (VD_AGENT_REGISTRY_KEY) +, _vdi_port (NULL) , _logon_desktop (false) , _display_setting_initialized (false) , _client_caps (NULL) @@ -186,8 +203,6 @@ VDAgent::VDAgent() _log = VDLog::get(log_path); } ZeroMemory(_input, sizeof(INPUT)); -ZeroMemory(_pipe_state, sizeof(VDPipeState)); -MUTEX_INIT(_write_mutex); MUTEX_INIT(_control_mutex); MUTEX_INIT(_message_mutex); @@ -196,6 +211,7 @@ VDAgent::VDAgent() VDAgent::~VDAgent() { +delete _events; delete _log; delete[] _client_caps; } @@ -260,7 +276,8 @@ bool VDAgent::run() if (_desktop_layout-get_display_count() == 0) { vd_printf(No QXL devices!); } -if (!connect_pipe()) { +if (!init_vdi_port()) { +vd_printf(Failed to create VDIPort instance); cleanup(); return false; } @@ -272,7 +289,14 @@ bool VDAgent::run() return false;
[Spice-devel] [PATCH 4/5] vdagent: remove pipe common defs
--- common/vdcommon.h | 31 --- 1 files changed, 0 insertions(+), 31 deletions(-) diff --git a/common/vdcommon.h b/common/vdcommon.h index 394333b..e50f2b0 100644 --- a/common/vdcommon.h +++ b/common/vdcommon.h @@ -32,19 +32,8 @@ typedef CRITICAL_SECTION mutex_t; #define MUTEX_LOCK(mutex) EnterCriticalSection(mutex) #define MUTEX_UNLOCK(mutex) LeaveCriticalSection(mutex) -#define VD_SERVICE_PIPE_NAME TEXT(.\\pipe\\vdservicepipe) -#define VD_MESSAGE_HEADER_SIZE (sizeof(VDPipeMessage) + sizeof(VDAgentMessage)) -#define VD_PIPE_BUF_SIZE (1024 * 1024) #define VD_AGENT_REGISTRY_KEY SOFTWARE\\Red Hat\\Spice\\vdagent\\ -enum { -VD_AGENT_COMMAND, -VD_AGENT_RESET, -VD_AGENT_RESET_ACK, -VD_AGENT_QUIT, -VD_AGENT_SESSION_LOGON, -}; - #if defined __GNUC__ #define ALIGN_GCC __attribute__ ((packed)) #define ALIGN_VC @@ -57,25 +46,5 @@ enum { #define swprintf_s(buf, sz, format...) swprintf(buf, format) #endif -typedef struct ALIGN_VC VDPipeMessage { -uint32_t type; -uint32_t opaque; -uint32_t size; -uint8_t data[0]; -} ALIGN_GCC VDPipeMessage; - -typedef struct VDPipeBuffer { -OVERLAPPED overlap; -DWORD start; -DWORD end; -uint8_t data[VD_PIPE_BUF_SIZE]; -} VDPipeBuffer; - -typedef struct VDPipeState { -HANDLE pipe; -VDPipeBuffer write; -VDPipeBuffer read; -} VDPipeState; - #endif -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 5/5] vdagent: extract event_dispatcher from input_desktop_message_loop
--- vdagent/vdagent.cpp | 105 +++ 1 files changed, 56 insertions(+), 49 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 9bb0898..7495826 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -80,6 +80,7 @@ public: private: VDAgent(); void input_desktop_message_loop(); +void event_dispatcher(DWORD timeout, DWORD wake_mask); bool handle_mouse_event(VDAgentMouseState* state); bool handle_announce_capabilities(VDAgentAnnounceCapabilities* announce_capabilities, uint32_t msg_size); @@ -362,9 +363,7 @@ void VDAgent::handle_control_event() void VDAgent::input_desktop_message_loop() { TCHAR desktop_name[MAX_PATH]; -DWORD wait_ret; HDESK hdesk; -MSG msg; hdesk = OpenInputDesktop(0, FALSE, GENERIC_ALL); if (!hdesk) { @@ -412,53 +411,7 @@ void VDAgent::input_desktop_message_loop() } _hwnd_next_viewer = SetClipboardViewer(_hwnd); while (_running !_desktop_switch) { -int cont_read = _vdi_port-read(); -int cont_write = _vdi_port-write(); -bool cont = false; - -if (cont_read = 0 cont_write = 0) { -cont = cont_read || cont_write; -} else if (cont_read == VDI_PORT_ERROR || cont_write == VDI_PORT_ERROR) { -vd_printf(VDI Port error, read %d write %d, cont_read, cont_write); -_running = false; -break; -} else if (cont_read == VDI_PORT_RESET || cont_write == VDI_PORT_RESET) { -vd_printf(VDI Port reset, read %d write %d, cont_read, cont_write); -_running = false; -break; -} -if (cont_read) { -handle_port_in(); -} -if (cont_write) { -handle_port_out(); -} - -wait_ret = MsgWaitForMultipleObjectsEx(_events_count, _events, cont ? 0 : INFINITE, - QS_ALLINPUT, MWMO_ALERTABLE); -if (wait_ret == WAIT_OBJECT_0 + _events_count) { -while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { -TranslateMessage(msg); -DispatchMessage(msg); -} -continue; -} -switch (wait_ret) { -case WAIT_OBJECT_0 + VD_EVENT_CONTROL: -handle_control_event(); -break; -case WAIT_IO_COMPLETION: -case WAIT_TIMEOUT: -break; -default: -DWORD vdi_event = wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0; -if (vdi_event = 0 vdi_event _vdi_port-get_num_events()) { -_running = _vdi_port-handle_event(vdi_event); -} else { -vd_printf(MsgWaitForMultipleObjectsEx failed: %lu %lu, wait_ret, GetLastError()); -_running = false; -} -} +event_dispatcher(INFINITE, QS_ALLINPUT); } _desktop_switch = false; if (_pending_input) { @@ -471,6 +424,60 @@ void VDAgent::input_desktop_message_loop() CloseDesktop(hdesk); } +void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask) +{ +DWORD wait_ret; +MSG msg; + +int cont_read = _vdi_port-read(); +int cont_write = _vdi_port-write(); +bool cont = false; + +if (cont_read = 0 cont_write = 0) { +cont = cont_read || cont_write; +} else if (cont_read == VDI_PORT_ERROR || cont_write == VDI_PORT_ERROR) { +vd_printf(VDI Port error, read %d write %d, cont_read, cont_write); +_running = false; +return; +} else if (cont_read == VDI_PORT_RESET || cont_write == VDI_PORT_RESET) { +vd_printf(VDI Port reset, read %d write %d, cont_read, cont_write); +_running = false; +return; +} +if (cont_read) { +handle_port_in(); +} +if (cont_write) { +handle_port_out(); +} + +wait_ret = MsgWaitForMultipleObjects(_events_count, _events, FALSE, cont ? 0 : timeout, + wake_mask); + +if (wake_mask wait_ret == WAIT_OBJECT_0 + _events_count) { +while (PeekMessage(msg, NULL, 0, 0, PM_REMOVE)) { +TranslateMessage(msg); +DispatchMessage(msg); +} +return; +} +switch (wait_ret) { +case WAIT_OBJECT_0 + VD_EVENT_CONTROL: +handle_control_event(); +break; +case WAIT_TIMEOUT: +break; +default: +DWORD vdi_event = wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0; +if (vdi_event = 0 vdi_event _vdi_port-get_num_events()) { +_running = _vdi_port-handle_event(vdi_event); +} else { +vd_printf(MsgWaitForMultipleObjectsEx failed: %lu %lu, wait_ret, GetLastError()); +_running = false; +} +} +} + DWORD VDAgent::get_buttons_change(DWORD last_buttons_state, DWORD new_buttons_state, DWORD
[Spice-devel] [PATCH] vdagent: set timeout for next clipboard chunk instead of complete reception
currently: -handling client disconnect during clipboard data trasfer is buggy -agent also timeouts on large paste from client (10sec) therfore: -reduce VD_CLIPBOARD_TIMEOUT_MS to 3sec from previous clipboard chunk -remove _clipboard_event and use _control_event(CONTROL_CLIPBOARD) instead -use _clipboard_tick for clipboard timeout, updated on each clipboard chunk -use cleanup_in_msg() to reset incoming message state rhbz#833835 --- vdagent/vdagent.cpp | 67 ++- 1 files changed, 34 insertions(+), 33 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 7495826..9537b90 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -32,7 +32,7 @@ #define VD_AGENT_WINCLASS_NAME TEXT(VDAGENT) #define VD_INPUT_INTERVAL_MS20 #define VD_TIMER_ID 1 -#define VD_CLIPBOARD_TIMEOUT_MS 1 +#define VD_CLIPBOARD_TIMEOUT_MS 3000 #define VD_CLIPBOARD_FORMAT_MAX_TYPES 16 //FIXME: extract format/type stuff to win_vdagent_common for use by windows\platform.cpp as well @@ -107,7 +107,7 @@ private: DWORD get_cximage_format(uint32_t type); enum { owner_none, owner_guest, owner_client }; void set_clipboard_owner(int new_owner); -enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON }; +enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH, CONTROL_LOGON, CONTROL_CLIPBOARD }; void set_control_event(int control_command); void handle_control_event(); VDIChunk* new_chunk(DWORD bytes = 0); @@ -119,6 +119,7 @@ private: void set_display_depth(uint32_t depth); void load_display_setting(); bool send_announce_capabilities(bool request); +void cleanup_in_msg(); void cleanup(); private: @@ -126,13 +127,13 @@ private: HWND _hwnd; HWND _hwnd_next_viewer; int _clipboard_owner; +DWORD _clipboard_tick; DWORD _buttons_state; ULONG _mouse_x; ULONG _mouse_y; INPUT _input; DWORD _input_time; HANDLE _control_event; -HANDLE _clipboard_event; HANDLE* _events; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; @@ -174,12 +175,12 @@ VDAgent::VDAgent() : _hwnd (NULL) , _hwnd_next_viewer (NULL) , _clipboard_owner (owner_none) +, _clipboard_tick (0) , _buttons_state (0) , _mouse_x (0) , _mouse_y (0) , _input_time (0) , _control_event (NULL) -, _clipboard_event (NULL) , _events (NULL) , _in_msg (NULL) , _in_msg_pos (0) @@ -259,8 +260,7 @@ bool VDAgent::run() vd_printf(SetProcessShutdownParameters failed %lu, GetLastError()); } _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); -_clipboard_event = CreateEvent(NULL, FALSE, FALSE, NULL); -if (!_control_event || !_clipboard_event) { +if (!_control_event) { vd_printf(CreateEvent() failed: %lu, GetLastError()); cleanup(); return false; @@ -313,7 +313,6 @@ bool VDAgent::run() void VDAgent::cleanup() { CloseHandle(_control_event); -CloseHandle(_clipboard_event); delete _vdi_port; delete _desktop_layout; } @@ -353,6 +352,9 @@ void VDAgent::handle_control_event() _logon_occured = true; } break; +case CONTROL_CLIPBOARD: +_clipboard_tick = 0; +break; default: vd_printf(Unsupported control command %u, control_command); } @@ -641,11 +643,11 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size) if (_clipboard_owner != owner_client) { vd_printf(Received clipboard data from client while clipboard is not owned by client); -SetEvent(_clipboard_event); +set_control_event(CONTROL_CLIPBOARD); return false; } if (clipboard-type == VD_AGENT_CLIPBOARD_NONE) { -SetEvent(_clipboard_event); +set_control_event(CONTROL_CLIPBOARD); return false; } switch (clipboard-type) { @@ -666,7 +668,7 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size) } format = get_clipboard_format(clipboard-type); if (SetClipboardData(format, clip_data)) { -SetEvent(_clipboard_event); +set_control_event(CONTROL_CLIPBOARD); return true; } // We retry clipboard open-empty-set-close only when there is a timeout in on_clipboard_request() @@ -942,26 +944,16 @@ void VDAgent::on_clipboard_request(UINT format) return; } -// next clipboard event will be considered a reply to this request -ResetEvent(_clipboard_event); - -DWORD start_tick = GetTickCount(); -do { -DWORD wait_result = WaitForSingleObjectEx(_clipboard_event, 1000, TRUE); - -switch (wait_result) { -case WAIT_OBJECT_0: -return; -case WAIT_IO_COMPLETION: -case WAIT_TIMEOUT: -break; -default: -vd_printf(Wait error (%lu)\n, GetLastError()); -
[Spice-devel] [PATCH] libwdi driver installer: use specific static libs
-add Advapi32.lib ole32.lib, set RTL to MT instead of MD -otherwise it requires to install MS VC++ 2008 SP1 redist -solves libwdi error WDI_ERROR_NEEDS_ADMIN (-15) Unable to run process with required administrative privileges rhbz#857119 --- libwdi/.msvc/installer_x64_2008.vcproj | 10 ++ libwdi/.msvc/installer_x86_2008.vcproj | 10 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libwdi/.msvc/installer_x64_2008.vcproj b/libwdi/.msvc/installer_x64_2008.vcproj index 11d606b..366a47f 100644 --- a/libwdi/.msvc/installer_x64_2008.vcproj +++ b/libwdi/.msvc/installer_x64_2008.vcproj @@ -21,6 +21,7 @@ OutputDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper IntermediateDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper\installer_x64 ConfigurationType=1 + UseOfMFC=0 CharacterSet=1 Tool @@ -44,7 +45,7 @@ Optimization=0 AdditionalIncludeDirectories=..\msvc PreprocessorDefinitions=_CRT_SECURE_NO_WARNINGS; _WIN64 - RuntimeLibrary=3 + RuntimeLibrary=1 WarningLevel=3 DebugInformationFormat=3 / @@ -59,7 +60,7 @@ / Tool Name=VCLinkerTool - AdditionalDependencies=newdev.lib setupapi.lib + AdditionalDependencies=newdev.lib setupapi.lib Advapi32.lib ole32.lib OutputFile=$(OutDir)\installer_x64.exe GenerateDebugInformation=true SubSystem=1 @@ -92,6 +93,7 @@ OutputDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper IntermediateDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper\installer_x64 ConfigurationType=1 + UseOfMFC=0 CharacterSet=1 WholeProgramOptimization=1 @@ -116,7 +118,7 @@ Optimization=1 AdditionalIncludeDirectories=..\..\msvc PreprocessorDefinitions=_CRT_SECURE_NO_WARNINGS; _WIN64 - RuntimeLibrary=2 + RuntimeLibrary=0 WarningLevel=3 / Tool @@ -130,7 +132,7 @@ / Tool Name=VCLinkerTool - AdditionalDependencies=newdev.lib setupapi.lib + AdditionalDependencies=newdev.lib setupapi.lib Advapi32.lib ole32.lib OutputFile=$(OutDir)\installer_x64.exe GenerateDebugInformation=false SubSystem=1 diff --git a/libwdi/.msvc/installer_x86_2008.vcproj b/libwdi/.msvc/installer_x86_2008.vcproj index eb58428..d0d00ea 100644 --- a/libwdi/.msvc/installer_x86_2008.vcproj +++ b/libwdi/.msvc/installer_x86_2008.vcproj @@ -21,6 +21,7 @@ OutputDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper IntermediateDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper\installer_x86 ConfigurationType=1 + UseOfMFC=0 CharacterSet=1 Tool @@ -44,7 +45,7 @@ AdditionalIncludeDirectories=..\..\msvc PreprocessorDefinitions=_CRT_SECURE_NO_WARNINGS MinimalRebuild=true - RuntimeLibrary=3 + RuntimeLibrary=1 WarningLevel=3 DebugInformationFormat=3 / @@ -59,7 +60,7 @@ / Tool Name=VCLinkerTool - AdditionalDependencies=newdev.lib setupapi.lib + AdditionalDependencies=newdev.lib setupapi.lib Advapi32.lib ole32.lib OutputFile=$(OutDir)\installer_x86.exe GenerateDebugInformation=true SubSystem=1 @@ -92,6 +93,7 @@ OutputDirectory=$(SolutionDir)$(PlatformName)\$(ConfigurationName)\helper
Re: [Spice-devel] [PATCH spice-gtk 1/2] controller/win32: allow ActiveX connection on untrusted website
ack Marc-André Lureau wrote: Set low integrity on named-pipes. This bug was originally resolved as: https://bugzilla.redhat.com/show_bug.cgi?id=668980 Fixes regression: https://bugzilla.redhat.com/show_bug.cgi?id=844461 --- gtk/controller/Makefile.am | 2 + gtk/controller/spice-controller-listener.c | 3 +- gtk/controller/spice-foreign-menu-listener.c | 3 +- gtk/controller/win32-util.c | 111 +++ gtk/controller/win32-util.h | 30 5 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 gtk/controller/win32-util.c create mode 100644 gtk/controller/win32-util.h diff --git a/gtk/controller/Makefile.am b/gtk/controller/Makefile.am index 7bfa51b..f2abf93 100644 --- a/gtk/controller/Makefile.am +++ b/gtk/controller/Makefile.am @@ -56,6 +56,8 @@ libspice_controller_la_SOURCES += \ namedpipeconnection.h \ namedpipelistener.c \ namedpipelistener.h \ + win32-util.c\ + win32-util.h\ $(NULL) endif libspice_controller_la_LDFLAGS = \ diff --git a/gtk/controller/spice-controller-listener.c b/gtk/controller/spice-controller-listener.c index da1121e..0189848 100644 --- a/gtk/controller/spice-controller-listener.c +++ b/gtk/controller/spice-controller-listener.c @@ -25,6 +25,7 @@ #include windows.h #include namedpipe.h #include namedpipelistener.h +#include win32-util.h #endif #ifdef G_OS_UNIX @@ -89,7 +90,7 @@ spice_controller_listener_new (const gchar *address, GError **error) listener = G_OBJECT (spice_named_pipe_listener_new ()); -np = spice_named_pipe_new (addr, error); +np = spice_win32_user_pipe_new (addr, error); if (!np) { g_object_unref (listener); listener = NULL; diff --git a/gtk/controller/spice-foreign-menu-listener.c b/gtk/controller/spice-foreign-menu-listener.c index 8322a13..6693e21 100644 --- a/gtk/controller/spice-foreign-menu-listener.c +++ b/gtk/controller/spice-foreign-menu-listener.c @@ -25,6 +25,7 @@ #include windows.h #include namedpipe.h #include namedpipelistener.h +#include win32-util.h #endif #ifdef G_OS_UNIX @@ -91,7 +92,7 @@ spice_foreign_menu_listener_new (const gchar *address, GError **error) listener = G_OBJECT (spice_named_pipe_listener_new ()); -np = spice_named_pipe_new (addr, error); +np = spice_win32_user_pipe_new (addr, error); if (!np) { g_object_unref (listener); listener = NULL; diff --git a/gtk/controller/win32-util.c b/gtk/controller/win32-util.c new file mode 100644 index 000..4e3ec4c --- /dev/null +++ b/gtk/controller/win32-util.c @@ -0,0 +1,111 @@ +/* + Copyright (C) 2012 Red Hat, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see http://www.gnu.org/licenses/. +*/ + +#include win32-util.h +#include windows.h +#include sddl.h +#include aclapi.h + +gboolean +spice_win32_set_low_integrity (void* handle, GError **error) +{ +g_return_val_if_fail (handle != NULL, FALSE); +g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + +/* see also http://msdn.microsoft.com/en-us/library/bb625960.aspx */ +PSECURITY_DESCRIPTOR psd = NULL; +PACL psacl = NULL; +BOOL sacl_present = FALSE; +BOOL sacl_defaulted = FALSE; +char *emsg; +int errsv; +gboolean success = FALSE; + +if (!ConvertStringSecurityDescriptorToSecurityDescriptor (S:(ML;;NW;;;LW), + SDDL_REVISION_1, psd, NULL)) +goto failed; + +if (!GetSecurityDescriptorSacl (psd, sacl_present, psacl, sacl_defaulted)) +goto failed; + +if (SetSecurityInfo (handle, SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, + NULL, NULL, NULL, psacl) != ERROR_SUCCESS) +goto failed; + +success = TRUE; +goto end; + +failed: +errsv = GetLastError (); +emsg = g_win32_error_message (errsv); +g_set_error (error, G_IO_ERROR, + g_io_error_from_win32_error (errsv), + Error setting integrity: %s, + emsg); +g_free (emsg); + +end: +if (psd != NULL) +LocalFree (psd); + +return
Re: [Spice-devel] [PATCH spice-gtk 2/2] controller/win32: limit access to current user only
ack Marc-André Lureau wrote: Based on RHEV spicec-win only code. --- gtk/controller/win32-util.c | 50 - 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/gtk/controller/win32-util.c b/gtk/controller/win32-util.c index 4e3ec4c..1268b2a 100644 --- a/gtk/controller/win32-util.c +++ b/gtk/controller/win32-util.c @@ -64,17 +64,63 @@ end: return success; } + +static gboolean +get_user_security_attributes (SECURITY_ATTRIBUTES* psa, SECURITY_DESCRIPTOR* psd, PACL* ppdacl) +{ +EXPLICIT_ACCESS ea; +TRUSTEE trst; +DWORD ret = 0; + +ZeroMemory (psa, sizeof (*psa)); +ZeroMemory (psd, sizeof (*psd)); +psa-nLength = sizeof (*psa); +psa-bInheritHandle = FALSE; +psa-lpSecurityDescriptor = psd; + +ZeroMemory (trst, sizeof (trst)); +trst.pMultipleTrustee = NULL; +trst.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; +trst.TrusteeForm = TRUSTEE_IS_NAME; +trst.TrusteeType = TRUSTEE_IS_USER; +trst.ptstrName = CURRENT_USER; + +ZeroMemory (ea, sizeof (ea)); +ea.grfAccessPermissions = GENERIC_WRITE | GENERIC_READ; +ea.grfAccessMode = SET_ACCESS; +ea.grfInheritance = NO_INHERITANCE; +ea.Trustee = trst; + +ret = SetEntriesInAcl (1, ea, NULL, ppdacl); +if (ret != ERROR_SUCCESS) +return FALSE; + + if (!InitializeSecurityDescriptor (psd, SECURITY_DESCRIPTOR_REVISION)) + return FALSE; + + if (!SetSecurityDescriptorDacl (psd, TRUE, *ppdacl, FALSE)) + return FALSE; + + return TRUE; +} + #define DEFAULT_PIPE_BUF_SIZE 4096 SpiceNamedPipe* spice_win32_user_pipe_new (gchar *name, GError **error) { +SECURITY_ATTRIBUTES sa; +SECURITY_DESCRIPTOR sd; +PACL dacl = NULL; HANDLE pipe; SpiceNamedPipe *np = NULL; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (error != NULL, NULL); +if (!get_user_security_attributes (sa, sd, dacl)) +return NULL; + pipe = CreateNamedPipe (name, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | /* FIXME: why is FILE_FLAG_FIRST_PIPE_INSTANCE needed for WRITE_DAC @@ -84,7 +130,7 @@ spice_win32_user_pipe_new (gchar *name, GError **error) PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE, -0, NULL); +0, sa); if (pipe == INVALID_HANDLE_VALUE) { int errsv = GetLastError (); @@ -107,5 +153,7 @@ spice_win32_user_pipe_new (gchar *name, GError **error) NULL, error, handle, pipe, NULL)); end: +LocalFree (dacl); + return np; } ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH] win-usb-driver: use usbclerk new message: USB_CLERK_DRIVER_SESSION_INSTALL
ack. seems ok, although CreateFile can move to init. Uri Lublin wrote: With this message usbclerk keeps a list of devices for which a libusb driver was installed (per connection). When a spice-gtk client exits, the connection is closed, and usbclerk uninstalls the driver for all devices in the list. That means we need to keep the connection open, so added the win-usb driver installer to usb-device-manager's priv. This prevents the case were the user exits the client, while a usb device is connected to the guest, and can not use the device from the client machine. rhbz#869542 --- gtk/usb-device-manager.c | 19 -- gtk/win-usb-clerk.h |3 +- gtk/win-usb-driver-install.c | 56 - 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index 3684485..3f4c272 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -109,6 +109,9 @@ struct _SpiceUsbDeviceManagerPrivate { struct usbredirfilter_rule *redirect_on_connect_rules; int auto_conn_filter_rules_count; int redirect_on_connect_rules_count; +#ifdef G_OS_WIN32 +SpiceWinUsbDriver *installer; +#endif #endif GPtrArray *devices; GPtrArray *channels; @@ -302,6 +305,10 @@ static void spice_usb_device_manager_finalize(GObject *gobject) if (priv-event_thread) g_thread_join(priv-event_thread); free(priv-auto_conn_filter_rules); +#ifdef G_OS_WIN32 +if (priv-installer) +g_object_unref(priv-installer); +#endif #endif g_free(priv-auto_connect_filter); @@ -876,7 +883,6 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject, status = spice_win_usb_driver_install_finish(installer, res, err); -g_object_unref(installer); spice_usb_device_unref(device); spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_NONE); @@ -1209,7 +1215,10 @@ void spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, UsbInstallCbInfo *cbinfo; spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_INSTALLING); -installer = spice_win_usb_driver_new(); +if (! self-priv-installer) { +self-priv-installer = spice_win_usb_driver_new(); +} +installer = self-priv-installer; cbinfo = g_new0(UsbInstallCbInfo, 1); cbinfo-manager = self; cbinfo-device = spice_usb_device_ref(device); @@ -1273,9 +1282,13 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self, UsbInstallCbInfo *cbinfo; g_warn_if_fail(device != NULL); +g_warn_if_fail(self-priv-installer != NULL); spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING); -installer = spice_win_usb_driver_new(); +if (! self-priv-installer) { +self-priv-installer = spice_win_usb_driver_new(); +} +installer = self-priv-installer; cbinfo = g_new0(UsbInstallCbInfo, 1); cbinfo-manager = self; cbinfo-device = spice_usb_device_ref(device); diff --git a/gtk/win-usb-clerk.h b/gtk/win-usb-clerk.h index 5b1e3cf..24da3b4 100644 --- a/gtk/win-usb-clerk.h +++ b/gtk/win-usb-clerk.h @@ -5,7 +5,7 @@ #define USB_CLERK_PIPE_NAME TEXT(.\\pipe\\usbclerkpipe) #define USB_CLERK_MAGIC 0xDADA -#define USB_CLERK_VERSION 0x0002 +#define USB_CLERK_VERSION 0x0003 typedef struct USBClerkHeader { UINT16 magic; @@ -18,6 +18,7 @@ enum { USB_CLERK_DRIVER_INSTALL = 1, USB_CLERK_DRIVER_REMOVE, USB_CLERK_REPLY, +USB_CLERK_DRIVER_SESSION_INSTALL, USB_CLERK_END_MESSAGE, }; diff --git a/gtk/win-usb-driver-install.c b/gtk/win-usb-driver-install.c index 02d20d6..1d68296 100644 --- a/gtk/win-usb-driver-install.c +++ b/gtk/win-usb-driver-install.c @@ -113,7 +113,6 @@ void win_usb_driver_handle_reply_cb(GObject *gobject, g_warn_if_fail(g_input_stream_close(istream, NULL, NULL)); g_clear_object(istream); -spice_win_usb_driver_close(self); if (err) { g_warning(failed to read reply from usbclerk (%s), err-message); @@ -149,7 +148,10 @@ void win_usb_driver_handle_reply_cb(GObject *gobject, if (priv-reply.hdr.version != USB_CLERK_VERSION) { g_warning(usbclerk version mismatch: mine=0x%04x server=0x%04x, USB_CLERK_VERSION, priv-reply.hdr.version); -/* For now just warn, do not fail */ +g_simple_async_result_set_error(priv-result, +SPICE_WIN_USB_DRIVER_ERROR, +SPICE_WIN_USB_DRIVER_ERROR_MESSAGE, +usbclerk version mismatch); } if (priv-reply.hdr.type != USB_CLERK_REPLY) { @@ -265,30 +267,39 @@ void spice_win_usb_driver_op(SpiceWinUsbDriver *self, priv = self-priv; -g_return_if_fail(priv-result == NULL); - result = g_simple_async_result_new(G_OBJECT(self), callback, user_data,
Re: [Spice-devel] [RFC] Implement of file drag-and-drop between host and guest
Alon Levy wrote: We could also use the existing SPICE_CLIENT_AGENT_DATA message, extending the ports to include an additional client port, keeping it compatible with multiple clients in the future. But otoh I like that your suggestion is simpler, I don't like that multiplexing that much. Adding d'n'd support to the agent and extending the agent protocol looks simpler/better than adding a new daemon. It also has some similarities to clipboard sharing. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] RFC: vdagent-win and virtio-serial
Hi, I'd like to make a small change in vdagent-win: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run separately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug Comments anyone? Thanks, Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] RFC: vdagent-win and virtio-serial
Marc-André Lureau wrote: Hi - Mensaje original - I'd like to make a small change in vdagent-win: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run separately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug Comments anyone? What is the drawback? Wasn't the idea to have one service and an agent per user? (that's how it works on Linux) How does that work today on Windows? it will stay that way :) cons: when switching between users client will switch to server mode for a few ms ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] RFC: vdagent-win and virtio-serial
David Jaša wrote: Hi Arnon, I've hit recently an issue with vdagent-win that after I performed fast user switch, the agent or service kept crashing - probably because the vdagent competed over non-shareable resource. I know it is a corner case, but still - wouldn't move of virtio-serial communication to per-user agent make such scenario unfixable? David same as before, at each moment only a single agent will run - on the active session. what you have mentioned seems like a bug, and it will be even easier to fix it that way. Arnon Gilboa píše v Čt 18. 10. 2012 v 12:26 +0200: Hi, I'd like to make a small change in vdagent-win: -move virtio-serial use from vdservice to vdagent -remove named pipe between vdservice vdagent pros: -make agent independent so it can run separately without service (e.g. single user, testing) -simplify service to just a launcher of agents -performance - data is currently copied on pipe read/write -separation between user sessions, no communication with service -easier to debug Comments anyone? Thanks, Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH] snd channel: fix accessing freed memory
ack Yonit Halperin wrote: snd_channel_put freed channel, and then channel-worker was accessed. It caused segmentation faults during connections and disconnections of the client. --- server/snd_worker.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/snd_worker.c b/server/snd_worker.c index a12397e..bc7be51 100644 --- a/server/snd_worker.c +++ b/server/snd_worker.c @@ -214,9 +214,9 @@ static void snd_disconnect_channel(SndChannel *channel) return; } spice_debug(%p, channel); +worker = channel-worker; if (channel-stream) { channel-cleanup(channel); -worker = channel-worker; red_channel_client_disconnect(worker-connection-channel_client); core-watch_remove(channel-stream-watch); channel-stream-watch = NULL; @@ -225,7 +225,7 @@ static void snd_disconnect_channel(SndChannel *channel) spice_marshaller_destroy(channel-send_data.marshaller); } snd_channel_put(channel); -channel-worker-connection = NULL; +worker-connection = NULL; } static void snd_playback_free_frame(PlaybackChannel *playback_channel, AudioFrame *frame) ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Failed to compile spice client for windows x86_64
Christophe Fergeau wrote: On Wed, Oct 10, 2012 at 10:02:48AM +0800, me,apporc wrote: I feel it 's wired, there must be something wrong with this source code. Because i need some features from new version spice client, usb redir eg. I have to compile it from source. Could any one give me some help? Thanks in advance. If you want USB redirection, you'll need spice-gtk and remote-viewer (comes with virt-viewer), not the spice client that comes with spice server sources. It's generally recommended to use tarballs when building from Windows as we ship some files that are complicated to generate on Windows in the tarballs. hope that helps, Christophe As Christophe mentioned, you are using the legacy spicec client which is no longer updated. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [vdagent-win 1/5] build-sys: Fix autogen.sh permissions
ACK series Acked-by: Arnon Gilboa agil...@redhat.com Christophe Fergeau wrote: It needs to be executable to be useful --- 0 files changed mode change 100644 = 100755 autogen.sh diff --git a/autogen.sh b/autogen.sh old mode 100644 new mode 100755 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 1/3] vdservice: restart vdagent if killed manually
win7-only issue rhbz#845222 --- vdservice/vdservice.cpp | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 696f3da..b48cbeb 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -590,6 +590,16 @@ bool VDService::execute() restart_agent(false); } else if (_system_version == SYS_VER_WIN_7_CLASS) { kill_agent(); +// Assume agent was killed due to console disconnect, and wait for agent +// normal restart due to console connect. If the agent is not alive yet, +// it was killed manually (or crashed), so let's restart it. +if (WaitForSingleObject(_control_event, VD_AGENT_RESTART_INTERVAL) == +WAIT_OBJECT_0) { +handle_control_event(); +} +if (_running !_agent_alive) { +restart_agent(false); +} } } else { if (wait_ret = WAIT_OBJECT_0 + _events_vdi_port_base -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 2/3] vdservice: retry virtio-serial read on ERROR_NO_SYSTEM_RESOURCES (1450)
as recommended by MS. seems like defined behavior of the driver. rhbz#839564 --- vdservice/virtio_vdi_port.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/vdservice/virtio_vdi_port.cpp b/vdservice/virtio_vdi_port.cpp index 31a3862..92eb129 100644 --- a/vdservice/virtio_vdi_port.cpp +++ b/vdservice/virtio_vdi_port.cpp @@ -167,7 +167,7 @@ void VirtioVDIPort::read_completion() if (!GetOverlappedResult(_handle, _read.overlap, bytes, FALSE)) { DWORD err = GetLastError(); -if (err == ERROR_OPERATION_ABORTED) { +if (err == ERROR_OPERATION_ABORTED || err == ERROR_NO_SYSTEM_RESOURCES) { _read.pending = false; return; } else if (err != ERROR_MORE_DATA) { -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 3/3] vdservice: stop service on virtio failure
read write are async, and their completion is handled by handle_event(), which returns status used by service execute loop. previously an error in GetOverlappedResult caused vdservice hang. rhbz#839564 --- vdservice/pci_vdi_port.cpp|3 ++- vdservice/pci_vdi_port.h |2 +- vdservice/vdi_port.h |2 +- vdservice/vdservice.cpp | 13 + vdservice/virtio_vdi_port.cpp | 24 +++- vdservice/virtio_vdi_port.h |6 +++--- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/vdservice/pci_vdi_port.cpp b/vdservice/pci_vdi_port.cpp index 4deace1..7466fbc 100644 --- a/vdservice/pci_vdi_port.cpp +++ b/vdservice/pci_vdi_port.cpp @@ -124,8 +124,9 @@ int PCIVDIPort::read() return n; } -void PCIVDIPort::handle_event(int event) +bool PCIVDIPort::handle_event(int event) { // do nothing - the event merely serves to wake us up, then we call read/write // at VDService::execute start of while(_running) loop. +return true; } diff --git a/vdservice/pci_vdi_port.h b/vdservice/pci_vdi_port.h index caa990f..fcc76dc 100644 --- a/vdservice/pci_vdi_port.h +++ b/vdservice/pci_vdi_port.h @@ -41,7 +41,7 @@ public: virtual int read(); virtual unsigned get_num_events() { return PCI_VDI_PORT_EVENT_COUNT; } virtual void fill_events(HANDLE* handles); -virtual void handle_event(int event); +virtual bool handle_event(int event); private: HANDLE _handle; diff --git a/vdservice/vdi_port.h b/vdservice/vdi_port.h index 50c4d29..a0fb20e 100644 --- a/vdservice/vdi_port.h +++ b/vdservice/vdi_port.h @@ -61,7 +61,7 @@ public: virtual bool init() = 0; virtual unsigned get_num_events() = 0; virtual void fill_events(HANDLE* handles) = 0; -virtual void handle_event(int event) = 0; +virtual bool handle_event(int event) = 0; virtual int write() = 0; virtual int read() = 0; diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index b48cbeb..2b925fd 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -130,7 +130,6 @@ private: bool _running; VDLog* _log; unsigned _events_count; -unsigned _events_vdi_port_base; }; VDService* VDService::_singleton = NULL; @@ -185,7 +184,6 @@ VDService::VDService() , _running (false) , _log (NULL) , _events_count(0) -, _events_vdi_port_base(0) { ZeroMemory(_agent_proc_info, sizeof(_agent_proc_info)); ZeroMemory(_pipe_state, sizeof(_pipe_state)); @@ -536,13 +534,12 @@ bool VDService::execute() vd_printf(created %s, _vdi_port-name()); _events_count = VD_STATIC_EVENTS_COUNT + _vdi_port-get_num_events() + 1 /*for agent*/; _events = new HANDLE[_events_count]; -_events_vdi_port_base = VD_STATIC_EVENTS_COUNT; ZeroMemory(_events, _events_count); vd_printf(Connected to server); _events[VD_EVENT_PIPE_READ] = _pipe_state.read.overlap.hEvent; _events[VD_EVENT_PIPE_WRITE] = _pipe_state.write.overlap.hEvent; _events[VD_EVENT_CONTROL] = _control_event; -_vdi_port-fill_events(_events[_events_vdi_port_base]); +_vdi_port-fill_events(_events[VD_STATIC_EVENTS_COUNT]); _chunk_size = _chunk_port = 0; read_pipe(); while (_running) { @@ -602,12 +599,12 @@ bool VDService::execute() } } } else { -if (wait_ret = WAIT_OBJECT_0 + _events_vdi_port_base -wait_ret WAIT_OBJECT_0 + - _events_vdi_port_base + _vdi_port-get_num_events()) { -_vdi_port-handle_event(wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0); +int vdi_event = wait_ret - VD_STATIC_EVENTS_COUNT - WAIT_OBJECT_0; +if (vdi_event = 0 vdi_event _vdi_port-get_num_events()) { +_running = _vdi_port-handle_event(vdi_event); } else { vd_printf(WaitForMultipleObjects failed %lu, GetLastError()); +_running = false; } } } diff --git a/vdservice/virtio_vdi_port.cpp b/vdservice/virtio_vdi_port.cpp index 92eb129..be5568a 100644 --- a/vdservice/virtio_vdi_port.cpp +++ b/vdservice/virtio_vdi_port.cpp @@ -51,17 +51,21 @@ void VirtioVDIPort::fill_events(HANDLE* handles) { handles[VIRTIO_VDI_PORT_EVENT_READ] = _read.overlap.hEvent; } -void VirtioVDIPort::handle_event(int event) { +bool VirtioVDIPort::handle_event(int event) { +bool ret; + switch (event) { case VIRTIO_VDI_PORT_EVENT_WRITE: -write_completion(); +ret = write_completion(); break; case VIRTIO_VDI_PORT_EVENT_READ: -read_completion(); +ret = read_completion(); break; default: vd_printf(ERROR: unexpected event %d, event); +ret = false; } +
[Spice-devel] [PATCH] usbclerk: add temporary driver install per session
-add message type USB_CLERK_DRIVER_SESSION_INSTALL, bump version to 3 -handle multiple pipe connections concurrently with thread for each one -keep pipe open, and on pipe close - cleanup the session-specific devices -add test for temporary driver install and multiple devices rhbz#845216 --- usbclerk.cpp | 101 ++--- usbclerk.h |3 +- usbclerktest.cpp | 79 -- 3 files changed, 120 insertions(+), 63 deletions(-) diff --git a/usbclerk.cpp b/usbclerk.cpp index 9ce12b8..464c0cb 100644 --- a/usbclerk.cpp +++ b/usbclerk.cpp @@ -4,6 +4,7 @@ #include stdio.h #include string.h #include tchar.h +#include list #include usbclerk.h #include usbredirfilter.h #include libwdi.h @@ -26,6 +27,13 @@ #define MAX_DEVICE_HCID_LEN 1024 #define MAX_DEVICE_FILTER_LEN 1024 +typedef struct USBDev { +UINT16 vid; +UINT16 pid; +} USBDev; + +typedef std::listUSBDev USBDevs; + class USBClerk { public: static USBClerk* get(); @@ -37,7 +45,7 @@ public: private: USBClerk(); bool execute(); -bool dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply); +bool dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply, USBDevs *devs); bool install_winusb_driver(int vid, int pid); bool remove_winusb_driver(int vid, int pid); bool uninstall_inf(HDEVINFO devs, PSP_DEVINFO_DATA dev_info); @@ -51,6 +59,7 @@ private: bool dev_filter_check(int vid, int pid, bool *has_winusb); static DWORD WINAPI control_handler(DWORD control, DWORD event_type, LPVOID event_data, LPVOID context); +static DWORD WINAPI pipe_thread(LPVOID param); static VOID WINAPI main(DWORD argc, TCHAR * argv[]); private: @@ -60,7 +69,6 @@ private: struct usbredirfilter_rule *_filter_rules; int _filter_count; char _wdi_path[MAX_PATH]; -HANDLE _pipe; bool _running; VDLog* _log; }; @@ -276,11 +284,9 @@ bool USBClerk::execute() { SECURITY_ATTRIBUTES sec_attr; SECURITY_DESCRIPTOR* sec_desr; -USBClerkReply reply = {{USB_CLERK_MAGIC, USB_CLERK_VERSION, -USB_CLERK_REPLY, sizeof(USBClerkReply)}}; CHAR filter_str[MAX_DEVICE_FILTER_LEN]; -CHAR buffer[USB_CLERK_PIPE_BUF_SIZE]; -DWORD bytes; +HANDLE pipe, thread; +DWORD tid; HKEY hkey; LONG ret; @@ -296,14 +302,6 @@ bool USBClerk::execute() sec_attr.nLength = sizeof(sec_attr); sec_attr.bInheritHandle = TRUE; sec_attr.lpSecurityDescriptor = sec_desr; -_pipe = CreateNamedPipe(USB_CLERK_PIPE_NAME, PIPE_ACCESS_DUPLEX | -FILE_FLAG_FIRST_PIPE_INSTANCE, -PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, -USB_CLERK_PIPE_BUF_SIZE, USB_CLERK_PIPE_BUF_SIZE, 0, sec_attr); -if (_pipe == INVALID_HANDLE_VALUE) { -vd_printf(CreatePipe() failed: %u, GetLastError()); -return false; -} /* Read filter rules from registry */ ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, LSoftware\\USBClerk, 0, KEY_READ, hkey); @@ -323,34 +321,60 @@ bool USBClerk::execute() RegCloseKey(hkey); } while (_running) { -if (!ConnectNamedPipe(_pipe, NULL) GetLastError() != ERROR_PIPE_CONNECTED) { -vd_printf(ConnectNamedPipe() failed: %u, GetLastError()); +pipe = CreateNamedPipe(USB_CLERK_PIPE_NAME, PIPE_ACCESS_DUPLEX, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, USB_CLERK_PIPE_BUF_SIZE, + USB_CLERK_PIPE_BUF_SIZE, 0, sec_attr); +if (pipe == INVALID_HANDLE_VALUE) { +vd_printf(CreatePipe() failed: %u, GetLastError()); break; } -if (!ReadFile(_pipe, buffer, sizeof(buffer), bytes, NULL)) { -vd_printf(ReadFile() failed: %d, GetLastError()); -goto disconnect; -} -if (!dispatch_message(buffer, bytes, reply)) { -goto disconnect; +if (!ConnectNamedPipe(pipe, NULL) GetLastError() != ERROR_PIPE_CONNECTED) { +vd_printf(ConnectNamedPipe() failed: %u, GetLastError()); +CloseHandle(pipe); +break; } -if (!WriteFile(_pipe, reply, sizeof(reply), bytes, NULL)) { -vd_printf(WriteFile() failed: %d, GetLastError()); -goto disconnect; +thread = CreateThread(NULL, 0, pipe_thread, (LPVOID)pipe, 0, tid); +if (thread == NULL) { +vd_printf(CreateThread() failed: %u, GetLastError()); +break; } -FlushFileBuffers(_pipe); -disconnect: -DisconnectNamedPipe(_pipe); +CloseHandle(thread); } free(_filter_rules); -CloseHandle(_pipe); return true; } -bool USBClerk::dispatch_message(CHAR *buffer,
Re: [Spice-devel] [PATCH 2/3] vdagent: don't stop due to UIPI blocking
Alon Levy wrote: ACK with one question. User Interface Privilege Isolation is usually used only for specific windows of system security applications (anti-viruses etc.), so with this patch mouse will be irresponsive for these windows but keep working for the rest. A complete solution might be switching to server mouse mode while the agent is still active. --- vdagent/vdagent.cpp | 11 --- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 3ffafe3..078e50f 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -429,9 +429,14 @@ bool VDAgent::send_input() return false; } } -if (!SendInput(1, _input, sizeof(INPUT)) GetLastError() != ERROR_ACCESS_DENIED) { -vd_printf(SendInput failed: %lu, GetLastError()); -ret = _running = false; +if (!SendInput(1, _input, sizeof(INPUT))) { +DWORD err = GetLastError(); +// Don't stop agent due to UIPI blocking, which is usually only for specific windows +// of system security applications (anti-viruses etc.) +if (err != ERROR_SUCCESS err != ERROR_ACCESS_DENIED) { layman question: Isn't there a more specific UIPI error code? I'm afraid there isn't one. This function fails when it is blocked by UIPI. Note that neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking. http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx +vd_printf(SendInput failed: %lu, err); +ret = _running = false; +} } _input_time = GetTickCount(); _desktop_layout-unlock(); -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 1/3] vdagent: add message_queue for messages written to pipe
This is only part of the message corruption solution. The other part is fixing virtio-serial / spice-qemu-char throttling code. -replace write_[lock/unlock/completion] calls with [new/enqueue]_message -remove clipboard specific _out_msg_* class members -remove ugly loop - while (a-_out_msg a-write_clipboard()); -add _message_mutex for message queue -fix pending_write race using _write_mutex -TODO: enqueue large message without dividing it to chunks in advance rhbz #846427 --- vdagent/vdagent.cpp | 186 +-- 1 files changed, 91 insertions(+), 95 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index b8bad44..3ffafe3 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -94,10 +94,10 @@ private: enum { CONTROL_STOP, CONTROL_DESKTOP_SWITCH }; void set_control_event(int control_command); void handle_control_event(); -uint8_t* write_lock(DWORD bytes = 0); -void write_unlock(DWORD bytes = 0); +VDPipeMessage* new_message(DWORD bytes = 0); +void enqueue_message(VDPipeMessage* msg); bool write_message(uint32_t type, uint32_t size, void* data); -bool write_clipboard(); +bool write_clipboard(VDAgentMessage* msg, uint32_t size); bool connect_pipe(); bool send_input(); void set_display_depth(uint32_t depth); @@ -119,9 +119,6 @@ private: HANDLE _clipboard_event; VDAgentMessage* _in_msg; uint32_t _in_msg_pos; -VDAgentMessage* _out_msg; -uint32_t _out_msg_pos; -uint32_t _out_msg_size; bool _pending_input; bool _pending_write; bool _running; @@ -131,7 +128,9 @@ private: VDPipeState _pipe_state; mutex_t _write_mutex; mutex_t _control_mutex; +mutex_t _message_mutex; std::queueint _control_queue; +std::queueVDPipeMessage* _message_queue; bool _logon_desktop; bool _display_setting_initialized; @@ -167,9 +166,6 @@ VDAgent::VDAgent() , _clipboard_event (NULL) , _in_msg (NULL) , _in_msg_pos (0) -, _out_msg (NULL) -, _out_msg_pos (0) -, _out_msg_size (0) , _pending_input (false) , _pending_write (false) , _running (false) @@ -193,6 +189,7 @@ VDAgent::VDAgent() ZeroMemory(_pipe_state, sizeof(VDPipeState)); MUTEX_INIT(_write_mutex); MUTEX_INIT(_control_mutex); +MUTEX_INIT(_message_mutex); _singleton = this; } @@ -538,7 +535,7 @@ bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port } DWORD msg_size = VD_MESSAGE_HEADER_SIZE + sizeof(VDAgentReply); -reply_pipe_msg = (VDPipeMessage*)write_lock(msg_size); +reply_pipe_msg = new_message(msg_size); if (!reply_pipe_msg) { return false; } @@ -553,10 +550,7 @@ bool VDAgent::handle_mon_config(VDAgentMonitorsConfig* mon_config, uint32_t port reply = (VDAgentReply*)reply_msg-data; reply-type = VD_AGENT_MONITORS_CONFIG; reply-error = display_count ? VD_AGENT_SUCCESS : VD_AGENT_ERROR; -write_unlock(msg_size); -if (!_pending_write) { -write_completion(0, 0, _pipe_state.write.overlap); -} +enqueue_message(reply_pipe_msg); return true; } @@ -669,7 +663,7 @@ bool VDAgent::send_announce_capabilities(bool request) uint32_t internal_msg_size = sizeof(VDAgentAnnounceCapabilities) + VD_AGENT_CAPS_BYTES; msg_size = VD_MESSAGE_HEADER_SIZE + internal_msg_size; -caps_pipe_msg = (VDPipeMessage*)write_lock(msg_size); +caps_pipe_msg = new_message(msg_size); if (!caps_pipe_msg) { return false; } @@ -694,10 +688,7 @@ bool VDAgent::send_announce_capabilities(bool request) for (uint32_t i = 0 ; i caps_size; ++i) { vd_printf(%X, caps-caps[i]); } -write_unlock(msg_size); -if (!_pending_write) { -write_completion(0, 0, _pipe_state.write.overlap); -} +enqueue_message(caps_pipe_msg); return true; } @@ -750,11 +741,10 @@ bool VDAgent::handle_display_config(VDAgentDisplayConfig* display_config, uint32 } msg_size = VD_MESSAGE_HEADER_SIZE + sizeof(VDAgentReply); -reply_pipe_msg = (VDPipeMessage*)write_lock(msg_size); +reply_pipe_msg = new_message(msg_size); if (!reply_pipe_msg) { return false; } - reply_pipe_msg-type = VD_AGENT_COMMAND; reply_pipe_msg-opaque = port; reply_pipe_msg-size = sizeof(VDAgentMessage) + sizeof(VDAgentReply); @@ -766,10 +756,7 @@ bool VDAgent::handle_display_config(VDAgentDisplayConfig* display_config, uint32 reply = (VDAgentReply*)reply_msg-data; reply-type = VD_AGENT_DISPLAY_CONFIG; reply-error = VD_AGENT_SUCCESS; -write_unlock(msg_size); -if (!_pending_write) { -write_completion(0, 0, _pipe_state.write.overlap); -} +enqueue_message(reply_pipe_msg); return true; } @@ -778,16 +765,13 @@ bool VDAgent::handle_control(VDPipeMessage* msg) switch (msg-type) { case VD_AGENT_RESET: { vd_printf(Agent
[Spice-devel] [PATCH 2/3] vdagent: don't stop due to UIPI blocking
User Interface Privilege Isolation is usually used only for specific windows of system security applications (anti-viruses etc.), so with this patch mouse will be irresponsive for these windows but keep working for the rest. A complete solution might be switching to server mouse mode while the agent is still active. --- vdagent/vdagent.cpp | 11 --- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 3ffafe3..078e50f 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -429,9 +429,14 @@ bool VDAgent::send_input() return false; } } -if (!SendInput(1, _input, sizeof(INPUT)) GetLastError() != ERROR_ACCESS_DENIED) { -vd_printf(SendInput failed: %lu, GetLastError()); -ret = _running = false; +if (!SendInput(1, _input, sizeof(INPUT))) { +DWORD err = GetLastError(); +// Don't stop agent due to UIPI blocking, which is usually only for specific windows +// of system security applications (anti-viruses etc.) +if (err != ERROR_SUCCESS err != ERROR_ACCESS_DENIED) { +vd_printf(SendInput failed: %lu, err); +ret = _running = false; +} } _input_time = GetTickCount(); _desktop_layout-unlock(); -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 3/3] vdservice: restart vdagent if killed manually
win7-only issue rhbz#845222 --- vdservice/vdservice.cpp | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 696f3da..b48cbeb 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -590,6 +590,16 @@ bool VDService::execute() restart_agent(false); } else if (_system_version == SYS_VER_WIN_7_CLASS) { kill_agent(); +// Assume agent was killed due to console disconnect, and wait for agent +// normal restart due to console connect. If the agent is not alive yet, +// it was killed manually (or crashed), so let's restart it. +if (WaitForSingleObject(_control_event, VD_AGENT_RESTART_INTERVAL) == +WAIT_OBJECT_0) { +handle_control_event(); +} +if (_running !_agent_alive) { +restart_agent(false); +} } } else { if (wait_ret = WAIT_OBJECT_0 + _events_vdi_port_base -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH] add registry key DisableSurfaces
ack w minor notes Alon Levy wrote: Presence of the key disables off screen surfaces creation; The callback is still registered, but it always fails. Registry key is checked on device initialization only, not during runtime, so you must reset the vm to see any affects. --- display/driver.c | 11 +++ display/driver.rc| 4 ++-- display/qxldd.h | 1 + include/qxl_driver.h | 2 ++ miniport/qxl.c | 47 ++- miniport/qxl.inf | 2 +- miniport/qxl.rc | 6 +++--- 7 files changed, 66 insertions(+), 7 deletions(-) diff --git a/display/driver.c b/display/driver.c index ef011ad..156befe 100644 --- a/display/driver.c +++ b/display/driver.c @@ -843,6 +843,13 @@ static BOOL PrepareHardware(PDev *pdev) pdev-dev_id = dev_info.dev_id; +pdev-create_non_primary_surfaces = dev_info.create_non_primary_surfaces; +DEBUG_PRINT((pdev, 1, %s: create_non_primary_surfaces = %d\n, __FUNCTION__, + pdev-create_non_primary_surfaces)); + +DEBUG_PRINT((NULL, 1, %s: 0x%lx exit: 0x%lx %ul\n, __FUNCTION__, pdev, + pdev-fb, pdev-fb_size)); + any reason you need this last dbg line? don't u have the same 2 lines below? CreateVRamSlot(pdev); DEBUG_PRINT((NULL, 1, %s: 0x%lx exit: 0x%lx %ul\n, __FUNCTION__, pdev, @@ -1409,6 +1416,10 @@ HBITMAP APIENTRY DrvCreateDeviceBitmap(DHPDEV dhpdev, SIZEL size, ULONG format) pdev = (PDev *)dhpdev; +if (!pdev-create_non_primary_surfaces) { +return FALSE; +} + if (!pdev-vram_slot_initialized || pdev-bitmap_format != format || pdev-fb == 0) { DEBUG_PRINT((pdev, 3, %s failed: %p: slot_initialized %d, format(%d,%d), fb %p\n, __FUNCTION__, pdev, pdev-vram_slot_initialized, diff --git a/display/driver.rc b/display/driver.rc index 4368925..ad449ba 100644 --- a/display/driver.rc +++ b/display/driver.rc @@ -16,12 +16,12 @@ #define VER_FILEDESCRIPTION_STR Red Hat QXL Display Driver #define VER_INTERNALNAME_STRqxldd.dll #define VER_ORIGINALFILENAME_STRVER_INTERNALNAME_STR -#define VER_FILEVERSION_STR 1.4.1.1 +#define VER_FILEVERSION_STR 1.4.2.3 #define VER_PRODUCTNAME_STR Spice #define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR #undef VER_PRODUCTVERSION -#define VER_PRODUCTVERSION 1,4,1,1 +#define VER_PRODUCTVERSION 1.4.2.3 shouldn't it be with ,s instead of .s ? #define VER_COMPANYNAME_STR Red Hat Inc. #define VER_LEGALCOPYRIGHT_STR � Red Hat Inc. All rights reserved. diff --git a/display/qxldd.h b/display/qxldd.h index d0166b5..1a1b5d5 100644 --- a/display/qxldd.h +++ b/display/qxldd.h @@ -220,6 +220,7 @@ typedef struct PDev { SIZEL resolution; UINT32 max_bitmap_size; ULONG bitmap_format; +UINT8 create_non_primary_surfaces; ULONG fb_size; BYTE* fb; diff --git a/include/qxl_driver.h b/include/qxl_driver.h index eac6f5f..677ee17 100644 --- a/include/qxl_driver.h +++ b/include/qxl_driver.h @@ -119,6 +119,8 @@ typedef struct QXLDriverInfo { UINT32 n_surfaces; UINT64 fb_phys; + +UINT8 create_non_primary_surfaces; } QXLDriverInfo; #endif diff --git a/miniport/qxl.c b/miniport/qxl.c index 003669b..bd449c3 100644 --- a/miniport/qxl.c +++ b/miniport/qxl.c @@ -95,6 +95,8 @@ typedef struct QXLExtension { char *log_buf; PUCHAR log_port; + +UINT8 create_non_primary_surfaces; } QXLExtension; #define QXL_ALLOC_TAG '_lxq' @@ -1002,6 +1004,47 @@ static VP_STATUS SetCustomDisplay(QXLExtension *dev_ext, QXLEscapeSetCustomDispl dev_ext-custom_mode); } +VP_STATUS QXLRegistryCallback( + PVOID HwDeviceExtension, + PVOID Context, + PWSTR ValueName, + PVOID ValueData, + ULONG ValueLength +) +{ +QXLExtension *dev_ext = HwDeviceExtension; +ULONG *key_ret = (ULONG *)Context; + +DEBUG_PRINT((dev_ext, 60, %s: length %d, first byte %d\n, __FUNCTION__, +ValueLength, (UINT8)ValueData)); + +if (key_ret) { +*key_ret = *(PULONG)ValueData; +} +return NO_ERROR; +} + +static UINT8 check_non_primary_surfaces_registry_key(QXLExtension *dev_ext) +{ +VP_STATUS ret; +ULONG key_ret; + +ret = VideoPortGetRegistryParameters( + dev_ext, + LDisableSurfaces, + FALSE, + QXLRegistryCallback, + key_ret); +if (ret == ERROR_INVALID_PARAMETER) { +dev_ext-create_non_primary_surfaces = 1; +DEBUG_PRINT((dev_ext, 0, %s: CreateNonPrimarySurfaces key doesn't exist, default to 1\n, +__FUNCTION__)); +} else { +dev_ext-create_non_primary_surfaces = 0; +} +return dev_ext-create_non_primary_surfaces; +} + BOOLEAN StartIO(PVOID dev_extension, PVIDEO_REQUEST_PACKET packet) { QXLExtension *dev_ext = dev_extension; @@ -1187,9 +1230,11 @@ BOOLEAN StartIO(PVOID
Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool.
I guess you'll need to add a new agent msg for setting the mouse mode, plus small changes in agent client, as so far agent existence meant using client mouse. It will be nice if you'll post your patches for this. Arnon Naga Mohan Pothula wrote: Arnon, I tried //ret = _running = falseearlier and noticed vdagent was not stopped but had seen mouse tracking offset issue. I can't stop VDService because VDAgent functionality is mandatory. As Yaniv suggestion, will it be possible keep running VDAgent and keeping server mode for such apps? Do you have any other ideas to fix this? Thanks\Naga. From: Yaniv Kaul yk...@redhat.com To: Arnon Gilboa agil...@redhat.com Cc: spice-devel@lists.freedesktop.org; Naga Mohan Pothula nagamohan.poth...@yahoo.com Sent: Wednesday, August 15, 2012 5:19 AM Subject: Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool. On 08/15/2012 01:05 PM, Arnon Gilboa wrote: Yaniv Kaul wrote: - Original Message - Hi Naga, Tested and reproduced it on Win7. I bet you'd see this in any many personal FW / Antivirus, to prevent a malicious software from manipulating it via the mouse (and disable it, for example). I'd try with ZoneAlarm (http://www.zonealarm.com/security/en-us/zonealarm-pc-security-free-firewall.htm#) for example, which I know has such protection. Y. Seems you are right. So the only option we have is (auto)fallback to server mode / usbtablet for such apps? If you can do it automatically, I guess so. Y. I don't have a patch yet for solving it, but you comment out the line: //ret = _running = false; so vdagent won't exit, although mouse will not be effective on such apps. If it's a must, meanwhile you can always switch back to server mouse mode by stopping vdservice. You can also use usbtablet in case you don't need vdagent functionality (multi mon, cp etc.) I'll update you when I have a patch ready (currently not top priority). Regards, Arnon Naga Mohan Pothula wrote: Hi Arnon, Have you checked installing kaspersky trail version? Here is the eror that causes vdagent.exe to be terminated abruptly. VDAgent::send_input::SendInput failed: 0 VDAgent::run::Agent stopped I've checked integrity level of Kaspersky UI process and it is lesser than VDAgent.exe Thanks/Naga. From: Arnon Gilboa agil...@redhat.comfail due to UIPI blocking To: Naga Mohan Pothula nagamohan.poth...@yahoo.com Cc: spice-devel@lists.freedesktop.org spice-devel@lists.freedesktop.org Sent: Sunday, August 5, 2012 9:54 AM Subject: Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool. Naga Mohan Pothula wrote: Hi, VDAgent in Windows 7 guest gets terminated when mouse hovers on some applications like Kaspersky Anti-virus tool. Noticed SendInput Windows API fails whenever any mouse operation performs on this tool. handle_mouse_event method returns with failure due to this and causes VDAgent to terminate. what's the error logged in %windir%\temp\vdagent.log? look for SendInput failed: ...) Initially, I thought it is UIPI ie., Process Integrity Level issue and observed as follows: VDService with SYSTEM a/c creates VDAgent with SYTEM a/c Kaspersky tool is service-based app with SYSTEM a/c creates process to handle UI with logged-on user and with 'Medium' Integrity level. Don't understand why SendInput API fails even VDAgent with higher integrity level than Kaspersky tool? Is there any other way to make VDAgent works for all applications installed in windows guest? will give it a look and update you accordingly. Thanks\Naga. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool.
Hi Naga, Tested and reproduced it on Win7. I don't have a patch yet for solving it, but you comment out the line: //ret = _running = false; so vdagent won't exit, although mouse will not be effective on such apps. If it's a must, meanwhile you can always switch back to server mouse mode by stopping vdservice. You can also use usbtablet in case you don't need vdagent functionality (multi mon, cp etc.) I'll update you when I have a patch ready (currently not top priority). Regards, Arnon Naga Mohan Pothula wrote: Hi Arnon, Have you checked installing kaspersky trail version? Here is the eror that causes vdagent.exe to be terminated abruptly. VDAgent::send_input::SendInput failed: 0 VDAgent::run::Agent stopped I've checked integrity level of Kaspersky UI process and it is lesser than VDAgent.exe Thanks/Naga. From: Arnon Gilboa agil...@redhat.comfail due to UIPI blocking To: Naga Mohan Pothula nagamohan.poth...@yahoo.com Cc: spice-devel@lists.freedesktop.org spice-devel@lists.freedesktop.org Sent: Sunday, August 5, 2012 9:54 AM Subject: Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool. Naga Mohan Pothula wrote: Hi, VDAgent in Windows 7 guest gets terminated when mouse hovers on some applications like Kaspersky Anti-virus tool. Noticed SendInput Windows API fails whenever any mouse operation performs on this tool. handle_mouse_event method returns with failure due to this and causes VDAgent to terminate. what's the error logged in %windir%\temp\vdagent.log? look for SendInput failed: ...) Initially, I thought it is UIPI ie., Process Integrity Level issue and observed as follows: VDService with SYSTEM a/c creates VDAgent with SYTEM a/c Kaspersky tool is service-based app with SYSTEM a/c creates process to handle UI with logged-on user and with 'Medium' Integrity level. Don't understand why SendInput API fails even VDAgent with higher integrity level than Kaspersky tool? Is there any other way to make VDAgent works for all applications installed in windows guest? will give it a look and update you accordingly. Thanks\Naga. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool.
Yaniv Kaul wrote: - Original Message - Hi Naga, Tested and reproduced it on Win7. I bet you'd see this in any many personal FW / Antivirus, to prevent a malicious software from manipulating it via the mouse (and disable it, for example). I'd try with ZoneAlarm (http://www.zonealarm.com/security/en-us/zonealarm-pc-security-free-firewall.htm#) for example, which I know has such protection. Y. Seems you are right. So the only option we have is (auto)fallback to server mode / usbtablet for such apps? I don't have a patch yet for solving it, but you comment out the line: //ret = _running = false; so vdagent won't exit, although mouse will not be effective on such apps. If it's a must, meanwhile you can always switch back to server mouse mode by stopping vdservice. You can also use usbtablet in case you don't need vdagent functionality (multi mon, cp etc.) I'll update you when I have a patch ready (currently not top priority). Regards, Arnon Naga Mohan Pothula wrote: Hi Arnon, Have you checked installing kaspersky trail version? Here is the eror that causes vdagent.exe to be terminated abruptly. VDAgent::send_input::SendInput failed: 0 VDAgent::run::Agent stopped I've checked integrity level of Kaspersky UI process and it is lesser than VDAgent.exe Thanks/Naga. From: Arnon Gilboa agil...@redhat.comfail due to UIPI blocking To: Naga Mohan Pothula nagamohan.poth...@yahoo.com Cc: spice-devel@lists.freedesktop.org spice-devel@lists.freedesktop.org Sent: Sunday, August 5, 2012 9:54 AM Subject: Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool. Naga Mohan Pothula wrote: Hi, VDAgent in Windows 7 guest gets terminated when mouse hovers on some applications like Kaspersky Anti-virus tool. Noticed SendInput Windows API fails whenever any mouse operation performs on this tool. handle_mouse_event method returns with failure due to this and causes VDAgent to terminate. what's the error logged in %windir%\temp\vdagent.log? look for SendInput failed: ...) Initially, I thought it is UIPI ie., Process Integrity Level issue and observed as follows: VDService with SYSTEM a/c creates VDAgent with SYTEM a/c Kaspersky tool is service-based app with SYSTEM a/c creates process to handle UI with logged-on user and with 'Medium' Integrity level. Don't understand why SendInput API fails even VDAgent with higher integrity level than Kaspersky tool? Is there any other way to make VDAgent works for all applications installed in windows guest? will give it a look and update you accordingly. Thanks\Naga. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Mouse failure happens when mouse hovers on some Apps like Kaspersky Anti-virus tool.
Naga Mohan Pothula wrote: Hi, VDAgent in Windows 7 guest gets terminated when mouse hovers on some applications like Kaspersky Anti-virus tool. Noticed SendInput Windows API fails whenever any mouse operation performs on this tool. handle_mouse_event method returns with failure due to this and causes VDAgent to terminate. what's the error logged in %windir%\temp\vdagent.log? look for SendInput failed: ...) Initially, I thought it is UIPI ie., Process Integrity Level issue and observed as follows: VDService with SYSTEM a/c creates VDAgent with SYTEM a/c Kaspersky tool is service-based app with SYSTEM a/c creates process to handle UI with logged-on user and with 'Medium' Integrity level. Don't understand why SendInput API fails even VDAgent with higher integrity level than Kaspersky tool? Is there any other way to make VDAgent works for all applications installed in windows guest? will give it a look and update you accordingly. Thanks\Naga. ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH 1/6] usbclerk: dos2unix
Thanks Hans, I'll fix that. Hans de Goede wrote: Hi, Series looks good, only remark I have is that with 6/6 you're not passing in interface information, that really is not a good idea, since for almost all devices if you want to filter on usb classes (which you usually do) the interesting bits are in the interface info. Now it might be that when usbclerk runs you don't know the configuration, but most devices have only 1 config, so for those that is not a problem :) For multi config devices, you can do as you do now and not pass in any interface info, or simply pass in the interface info for the currently active config. Note that what happens on the host side is that the filter gets run for the current config, and if the config changes it gets re-run with the new interface info. Regards, Hans On 07/23/2012 11:23 AM, Arnon Gilboa wrote: --- usbclerk.cpp | 72 +- 1 files changed, 36 insertions(+), 36 deletions(-) diff --git a/usbclerk.cpp b/usbclerk.cpp index 792f544..441f4a1 100644 --- a/usbclerk.cpp +++ b/usbclerk.cpp @@ -1,6 +1,6 @@ #include windows.h #include setupapi.h -#include cfgmgr32.h +#include cfgmgr32.h #include stdio.h #include string.h #include tchar.h @@ -37,8 +37,8 @@ private: bool dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply); bool install_winusb_driver(int vid, int pid); bool remove_winusb_driver(int vid, int pid); -bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info); -bool rescan(); +bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info); +bool rescan(); static DWORD WINAPI control_handler(DWORD control, DWORD event_type, LPVOID event_data, LPVOID context); static VOID WINAPI main(DWORD argc, TCHAR * argv[]); @@ -289,7 +289,7 @@ bool USBClerk::execute() if (!ConnectNamedPipe(_pipe, NULL) GetLastError() != ERROR_PIPE_CONNECTED) { vd_printf(ConnectNamedPipe() failed: %u, GetLastError()); break; -} +} if (!ReadFile(_pipe, buffer, sizeof(buffer), bytes, NULL)) { vd_printf(ReadFile() failed: %d, GetLastError()); goto disconnect; @@ -433,52 +433,52 @@ cleanup: bool USBClerk::remove_winusb_driver(int vid, int pid) { HDEVINFO devs; -DWORD dev_index; -SP_DEVINFO_DATA dev_info; +DWORD dev_index; +SP_DEVINFO_DATA dev_info; TCHAR dev_prefix[MAX_DEVICE_ID_LEN]; -TCHAR dev_id[MAX_DEVICE_ID_LEN]; -bool ret = false; +TCHAR dev_id[MAX_DEVICE_ID_LEN]; +bool ret = false; -devs = SetupDiGetClassDevs(NULL, LUSB, NULL, DIGCF_ALLCLASSES); +devs = SetupDiGetClassDevs(NULL, LUSB, NULL, DIGCF_ALLCLASSES); if (devs == INVALID_HANDLE_VALUE) { vd_printf(SetupDiGetClassDevsEx failed: %u, GetLastError()); return false; } swprintf(dev_prefix, MAX_DEVICE_ID_LEN, LUSB\\VID_%04xPID_%04x, vid, pid); -dev_info.cbSize = sizeof(dev_info); -for (dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, dev_info); dev_index++) { -if (SetupDiGetDeviceInstanceId(devs, dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) -wcsstr(dev_id, dev_prefix)) { -vd_printf(Removing %S, dev_id); -ret = remove_dev(devs, dev_info); -break; -} -} +dev_info.cbSize = sizeof(dev_info); +for (dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, dev_info); dev_index++) { +if (SetupDiGetDeviceInstanceId(devs, dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) +wcsstr(dev_id, dev_prefix)) { +vd_printf(Removing %S, dev_id); +ret = remove_dev(devs, dev_info); +break; +} +} SetupDiDestroyDeviceInfoList(devs); -ret = ret rescan(); +ret = ret rescan(); return ret; } -bool USBClerk::remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info) -{ -SP_REMOVEDEVICE_PARAMS rmd_params; - -rmd_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); -rmd_params.ClassInstallHeader.InstallFunction = DIF_REMOVE; -rmd_params.Scope = DI_REMOVEDEVICE_GLOBAL; -rmd_params.HwProfile = 0; -return (SetupDiSetClassInstallParams(devs, dev_info, -rmd_params.ClassInstallHeader, sizeof(rmd_params)) -SetupDiCallClassInstaller(DIF_REMOVE, devs, dev_info)); +bool USBClerk::remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info) +{ +SP_REMOVEDEVICE_PARAMS rmd_params; + +rmd_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); +rmd_params.ClassInstallHeader.InstallFunction = DIF_REMOVE; +rmd_params.Scope = DI_REMOVEDEVICE_GLOBAL; +rmd_params.HwProfile = 0; +return (SetupDiSetClassInstallParams(devs, dev_info, +rmd_params.ClassInstallHeader, sizeof(rmd_params)) +SetupDiCallClassInstaller(DIF_REMOVE
Re: [Spice-devel] [PATCH 6/6] usbclerk: add device filter support
Uri Lublin wrote: filter_rules should be initialized to NULL and filter_count to 0. In case they are not initialized by usbredirfilter_string_to_rules (e.g. if that registry entry does not exist). sure, already fixed, name was also with no _prefix... diff --git a/usbclerk.vcproj b/usbclerk.vcproj This can be moved to the previous commit, if you like. right, will make it be easier to revert when mingw'ed ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 2/6] usbclerk: move wdi driver extraction path to system32
prevents user from replacing the drivers --- usbclerk.cpp | 12 +++- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/usbclerk.cpp b/usbclerk.cpp index 441f4a1..9100811 100644 --- a/usbclerk.cpp +++ b/usbclerk.cpp @@ -17,7 +17,7 @@ #define USB_CLERK_LOG_PATH TEXT(%susbclerk.log) #define USB_CLERK_PIPE_TIMEOUT 1 #define USB_CLERK_PIPE_BUF_SIZE 1024 -#define USB_DRIVER_PATH %Swdi_usb_driver +#define USB_DRIVER_PATH %S\\wdi_usb_driver #define USB_DRIVER_INFNAME_LEN 64 #define USB_DRIVER_INSTALL_RETRIES 10 #define USB_DRIVER_INSTALL_INTERVAL 2000 @@ -206,13 +206,15 @@ VOID WINAPI USBClerk::main(DWORD argc, TCHAR* argv[]) SERVICE_STATUS* status; TCHAR log_path[MAX_PATH]; -TCHAR temp_path[MAX_PATH]; +TCHAR path[MAX_PATH]; -if (GetTempPath(MAX_PATH, temp_path)) { -sprintf_s(s-_wdi_path, MAX_PATH, USB_DRIVER_PATH, temp_path); -swprintf_s(log_path, MAX_PATH, USB_CLERK_LOG_PATH, temp_path); +if (GetTempPath(MAX_PATH, path)) { +swprintf_s(log_path, MAX_PATH, USB_CLERK_LOG_PATH, path); s-_log = VDLog::get(log_path); } +if (GetSystemDirectory(path, MAX_PATH)) { +sprintf_s(s-_wdi_path, MAX_PATH, USB_DRIVER_PATH, path); +} vd_printf(***Service started***); SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); status = s-_status; -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 4/6] usbclerk: refactor device lookup
--- usbclerk.cpp | 33 - 1 files changed, 20 insertions(+), 13 deletions(-) diff --git a/usbclerk.cpp b/usbclerk.cpp index e01489b..09f1e66 100644 --- a/usbclerk.cpp +++ b/usbclerk.cpp @@ -39,6 +39,7 @@ private: bool remove_winusb_driver(int vid, int pid); bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info); bool rescan(); +bool get_dev_info(HDEVINFO devs, int vid, int pid, SP_DEVINFO_DATA *dev_info); static DWORD WINAPI control_handler(DWORD control, DWORD event_type, LPVOID event_data, LPVOID context); static VOID WINAPI main(DWORD argc, TCHAR * argv[]); @@ -435,10 +436,7 @@ cleanup: bool USBClerk::remove_winusb_driver(int vid, int pid) { HDEVINFO devs; -DWORD dev_index; SP_DEVINFO_DATA dev_info; -TCHAR dev_prefix[MAX_DEVICE_ID_LEN]; -TCHAR dev_id[MAX_DEVICE_ID_LEN]; bool ret = false; devs = SetupDiGetClassDevs(NULL, LUSB, NULL, DIGCF_ALLCLASSES); @@ -446,16 +444,9 @@ bool USBClerk::remove_winusb_driver(int vid, int pid) vd_printf(SetupDiGetClassDevsEx failed: %u, GetLastError()); return false; } - -swprintf(dev_prefix, MAX_DEVICE_ID_LEN, LUSB\\VID_%04xPID_%04x, vid, pid); -dev_info.cbSize = sizeof(dev_info); -for (dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, dev_info); dev_index++) { -if (SetupDiGetDeviceInstanceId(devs, dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) -wcsstr(dev_id, dev_prefix)) { -vd_printf(Removing %S, dev_id); -ret = remove_dev(devs, dev_info); -break; -} +if (get_dev_info(devs, vid, pid, dev_info)) { +vd_printf(Removing %04x:%04x, vid, pid); +ret = remove_dev(devs, dev_info); } SetupDiDestroyDeviceInfoList(devs); ret = ret rescan(); @@ -497,6 +488,22 @@ bool USBClerk::rescan() return true; } +bool USBClerk::get_dev_info(HDEVINFO devs, int vid, int pid, SP_DEVINFO_DATA *dev_info) +{ +TCHAR dev_prefix[MAX_DEVICE_ID_LEN]; +TCHAR dev_id[MAX_DEVICE_ID_LEN]; + +swprintf(dev_prefix, MAX_DEVICE_ID_LEN, LUSB\\VID_%04xPID_%04x, vid, pid); +dev_info-cbSize = sizeof(*dev_info); +for (DWORD dev_index = 0; SetupDiEnumDeviceInfo(devs, dev_index, dev_info); dev_index++) { +if (SetupDiGetDeviceInstanceId(devs, dev_info, dev_id, MAX_DEVICE_ID_LEN, NULL) +wcsstr(dev_id, dev_prefix)) { +return true; +} +} +return false; +} + int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { bool success = false; -- 1.7.4.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH 5/6] usbclerk: add usbredirfilter stdint.h
until switching to mingw build --- stdint.h | 256 + usbredirfilter.c | 260 ++ usbredirfilter.h | 127 ++ 3 files changed, 643 insertions(+), 0 deletions(-) create mode 100644 stdint.h create mode 100644 usbredirfilter.c create mode 100644 usbredirfilter.h diff --git a/stdint.h b/stdint.h new file mode 100644 index 000..00988d9 --- /dev/null +++ b/stdint.h @@ -0,0 +1,256 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file was originally part of the w64 mingw-runtime package. + */ + +/* ISO C9x 7.18 Integer types stdint.h + * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * Contributor: Danny Smith danny_r_smith_2...@yahoo.co.nz + * Modified for libusb/MSVC: Pete Batard pbat...@gmail.com + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Date: 2010-04-02 + */ + +#ifndef _MSC_VER +#error This header should only be used with Microsoft compilers +#endif + +#ifndef _STDINT_H +#define _STDINT_H + +#ifndef _INTPTR_T_DEFINED +#define _INTPTR_T_DEFINED +#ifndef __intptr_t_defined +#define __intptr_t_defined +#undef intptr_t +#ifdef _WIN64 + typedef __int64 intptr_t; +#else + typedef int intptr_t; +#endif /* _WIN64 */ +#endif /* __intptr_t_defined */ +#endif /* _INTPTR_T_DEFINED */ + +#ifndef _UINTPTR_T_DEFINED +#define _UINTPTR_T_DEFINED +#ifndef __uintptr_t_defined +#define __uintptr_t_defined +#undef uintptr_t +#ifdef _WIN64 + typedef unsigned __int64 uintptr_t; +#else + typedef unsigned int uintptr_t; +#endif /* _WIN64 */ +#endif /* __uintptr_t_defined */ +#endif /* _UINTPTR_T_DEFINED */ + +#ifndef _PTRDIFF_T_DEFINED +#define _PTRDIFF_T_DEFINED +#ifndef _PTRDIFF_T_ +#define _PTRDIFF_T_ +#undef ptrdiff_t +#ifdef _WIN64 + typedef __int64 ptrdiff_t; +#else + typedef int ptrdiff_t; +#endif /* _WIN64 */ +#endif /* _PTRDIFF_T_ */ +#endif /* _PTRDIFF_T_DEFINED */ + +#ifndef _WCHAR_T_DEFINED +#define _WCHAR_T_DEFINED +#ifndef __cplusplus + typedef unsigned short wchar_t; +#endif /* C++ */ +#endif /* _WCHAR_T_DEFINED */ + +#ifndef _WCTYPE_T_DEFINED +#define _WCTYPE_T_DEFINED +#ifndef _WINT_T +#define _WINT_T + typedef unsigned short wint_t; + typedef unsigned short wctype_t; +#endif /* _WINT_T */ +#endif /* _WCTYPE_T_DEFINED */ + +/* 7.18.1.1 Exact-width integer types */ +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + +/* 7.18.1.2 Minimum-width integer types */ +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +typedef short int_least16_t; +typedef unsigned short uint_least16_t; +typedef int int_least32_t; +typedef unsigned uint_least32_t; +typedef __int64 int_least64_t; +typedef unsigned __int64 uint_least64_t; + +/* 7.18.1.3 Fastest minimum-width integer types + * Not actually guaranteed to be fastest for all purposes + * Here we use the exact-width types for 8 and 16-bit ints. + */ +typedef __int8 int_fast8_t; +typedef unsigned __int8 uint_fast8_t; +typedef __int16 int_fast16_t; +typedef unsigned __int16 uint_fast16_t; +typedef __int32 int_fast32_t; +typedef unsigned __int32 uint_fast32_t; +typedef __int64 int_fast64_t; +typedef unsigned __int64 uint_fast64_t; + +/* 7.18.1.5 Greatest-width integer types */ +typedef __int64 intmax_t; +typedef unsigned __int64 uintmax_t; + +/* 7.18.2 Limits of specified-width integer types */ + +/* 7.18.2.1 Limits of exact-width integer types */ +#define INT8_MIN (-128) +#define INT16_MIN (-32768) +#define INT32_MIN (-2147483647 - 1) +#define INT64_MIN (-9223372036854775807LL - 1) + +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#define INT64_MAX 9223372036854775807LL + +#define UINT8_MAX 255 +#define UINT16_MAX 65535 +#define UINT32_MAX 0xU /* 4294967295U */ +#define UINT64_MAX 0xULL /* 18446744073709551615ULL */ + +/* 7.18.2.2 Limits of minimum-width integer types */ +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define
[Spice-devel] [PATCH 6/6] usbclerk: add device filter support
read from HKLM\Software\USBClerk\filter_rules same format as in client --- usbclerk.cpp| 69 +++ usbclerk.vcproj | 40 +++ 2 files changed, 109 insertions(+), 0 deletions(-) diff --git a/usbclerk.cpp b/usbclerk.cpp index 09f1e66..2913998 100644 --- a/usbclerk.cpp +++ b/usbclerk.cpp @@ -5,6 +5,7 @@ #include string.h #include tchar.h #include usbclerk.h +#include usbredirfilter.h #include libwdi.h #include vdlog.h @@ -22,6 +23,8 @@ #define USB_DRIVER_INSTALL_RETRIES 10 #define USB_DRIVER_INSTALL_INTERVAL 2000 #define MAX_DEVICE_PROP_LEN 256 +#define MAX_DEVICE_HCID_LEN 1024 +#define MAX_DEVICE_FILTER_LEN 1024 class USBClerk { public: @@ -40,6 +43,7 @@ private: bool remove_dev(HDEVINFO devs, PSP_DEVINFO_DATA dev_info); bool rescan(); bool get_dev_info(HDEVINFO devs, int vid, int pid, SP_DEVINFO_DATA *dev_info); +bool dev_filter_check(int vid, int pid); static DWORD WINAPI control_handler(DWORD control, DWORD event_type, LPVOID event_data, LPVOID context); static VOID WINAPI main(DWORD argc, TCHAR * argv[]); @@ -48,6 +52,8 @@ private: static USBClerk* _singleton; SERVICE_STATUS _status; SERVICE_STATUS_HANDLE _status_handle; +struct usbredirfilter_rule *filter_rules; +int filter_count; char _wdi_path[MAX_PATH]; HANDLE _pipe; bool _running; @@ -265,8 +271,11 @@ bool USBClerk::execute() SECURITY_DESCRIPTOR* sec_desr; USBClerkReply reply = {{USB_CLERK_MAGIC, USB_CLERK_VERSION, USB_CLERK_REPLY, sizeof(USBClerkReply)}}; +CHAR filter_str[MAX_DEVICE_FILTER_LEN]; CHAR buffer[USB_CLERK_PIPE_BUF_SIZE]; DWORD bytes; +HKEY hkey; +LONG ret; #if 0 /* Hack for wdi logging */ @@ -288,6 +297,20 @@ bool USBClerk::execute() vd_printf(CreatePipe() failed: %u, GetLastError()); return false; } +ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, LSoftware\\USBClerk, 0, KEY_READ, hkey); +if (ret == ERROR_SUCCESS) { +DWORD size = sizeof(filter_str); +ret = RegQueryValueExA(hkey, filter_rules, NULL, NULL, (LPBYTE)filter_str, size); +if (ret == ERROR_SUCCESS) { +ret = usbredirfilter_string_to_rules(filter_str, ,, |, + filter_rules, filter_count); +if (ret != 0) { +vd_printf(Failed parsing filter rules: %s %d, filter_str, ret); +} +} +RegCloseKey(hkey); +} +vd_printf(filter_count: %d, filter_count); while (_running) { if (!ConnectNamedPipe(_pipe, NULL) GetLastError() != ERROR_PIPE_CONNECTED) { vd_printf(ConnectNamedPipe() failed: %u, GetLastError()); @@ -308,6 +331,7 @@ bool USBClerk::execute() disconnect: DisconnectNamedPipe(_pipe); } +free(filter_rules); CloseHandle(_pipe); return true; } @@ -326,6 +350,10 @@ bool USBClerk::dispatch_message(CHAR *buffer, DWORD bytes, USBClerkReply *reply) return false; } dev = (USBClerkDriverOp *)buffer; +if (!dev_filter_check(dev-vid, dev-pid)) { +reply-status = FALSE; +return true; +} switch (hdr-type) { case USB_CLERK_DRIVER_INSTALL: vd_printf(Installing winusb driver for %04x:%04x, dev-vid, dev-pid); @@ -504,6 +532,47 @@ bool USBClerk::get_dev_info(HDEVINFO devs, int vid, int pid, SP_DEVINFO_DATA *de return false; } +bool USBClerk::dev_filter_check(int vid, int pid) +{ +HDEVINFO devs; +SP_DEVINFO_DATA dev_info; +TCHAR compat_ids[MAX_DEVICE_HCID_LEN]; +uint8_t dev_cls, dev_subcls, dev_proto; +bool ret = false; + +if (!filter_rules) { +return true; +} +devs = SetupDiGetClassDevs(NULL, LUSB, NULL, DIGCF_ALLCLASSES); +if (devs == INVALID_HANDLE_VALUE) { +vd_printf(SetupDiGetClassDevsEx failed: %u, GetLastError()); +return false; +} +if (!get_dev_info(devs, vid, pid, dev_info)) { +vd_printf(Cannot find device info %04x:%04x, vid, pid); +goto cleanup; +} +if (!SetupDiGetDeviceRegistryProperty(devs, dev_info, SPDRP_COMPATIBLEIDS, NULL, +(PBYTE)compat_ids, sizeof(compat_ids), NULL)) { +vd_printf(Cannot get compatible id %04x:%04x, vid, pid); +goto cleanup; +} +if (swscanf_s(compat_ids, LUSB\\Class_%02hxSubClass_%02hxProt_%02hx, +dev_cls, dev_subcls, dev_proto) != 3) { +vd_printf(Cannot parse compatible id %S, compat_ids); +goto cleanup; +} +if (usbredirfilter_check(filter_rules, filter_count, dev_cls, dev_subcls, dev_proto, +NULL, NULL, NULL, 0, vid, pid, 0, 0) == 0) { +ret = true; +} else { +vd_printf(Device filter failed %04x:%04x, vid, pid); +} +cleanup: +SetupDiDestroyDeviceInfoList(devs); +return ret; +} + int
Re: [Spice-devel] [spice-gtk Win32 v3 01/12] namedpipe: add is_server property
ack Uri Lublin wrote: Currently only NamePipe server is available. We want to support also NamedPipe Client. This property is to be used in a following patch. --- gtk/controller/namedpipe.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/gtk/controller/namedpipe.c b/gtk/controller/namedpipe.c index 6859770..355887a 100644 --- a/gtk/controller/namedpipe.c +++ b/gtk/controller/namedpipe.c @@ -36,6 +36,7 @@ enum PROP_0, PROP_NAME, PROP_HANDLE, + PROP_IS_SERVER, }; struct _SpiceNamedPipePrivate @@ -44,6 +45,7 @@ struct _SpiceNamedPipePrivate GError * construct_error; guint inited : 1; HANDLEhandle; + gboolean is_server; }; static void @@ -124,6 +126,9 @@ spice_named_pipe_get_property (GObject*object, case PROP_HANDLE: g_value_set_pointer (value, np-priv-handle); break; + case PROP_IS_SERVER: +g_value_set_boolean (value, np-priv-is_server); +break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -146,6 +151,9 @@ spice_named_pipe_set_property (GObject *object, case PROP_HANDLE: np-priv-handle = g_value_get_pointer (value); break; +case PROP_IS_SERVER: +np-priv-is_server = g_value_get_boolean (value); +break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -179,6 +187,15 @@ spice_named_pipe_class_init (SpiceNamedPipeClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, PROP_IS_SERVER, + g_param_spec_boolean (isserver, +Server or Client, +Create or Connect a NamedPipe, + TRUE, + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } static void ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 v3 02/12] NamedPipe: spice_named_pipe_new: add param to distinguish Server or Client
ack Uri Lublin wrote: Currently both users are servers. --- gtk/controller/namedpipe.c | 24 +--- gtk/controller/namedpipe.h |4 +++- gtk/controller/spice-controller-listener.c |2 +- gtk/controller/spice-foreign-menu-listener.c |2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gtk/controller/namedpipe.c b/gtk/controller/namedpipe.c index 355887a..20dde4c 100644 --- a/gtk/controller/namedpipe.c +++ b/gtk/controller/namedpipe.c @@ -80,12 +80,21 @@ spice_named_pipe_constructed (GObject *object) pipe, in overlapped mode */ goto end; - np-priv-handle = CreateNamedPipe (np-priv-name, - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, - DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE, - 0, NULL); + if (np-priv-is_server) { + np-priv-handle = CreateNamedPipe (np-priv-name, + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE, + 0, NULL); + } else { + np-priv-handle = CreateFile (np-priv-name, + GENERIC_READ | GENERIC_WRITE, + 0, NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + } if (np-priv-handle == INVALID_HANDLE_VALUE) { @@ -244,11 +253,12 @@ spice_named_pipe_initable_iface_init (GInitableIface *iface) } SpiceNamedPipe * -spice_named_pipe_new (const gchar *name, GError **error) +spice_named_pipe_new (const gchar *name, const gboolean is_server, GError **error) { return SPICE_NAMED_PIPE (g_initable_new (SPICE_TYPE_NAMED_PIPE, NULL, error, name, name, + isserver, is_server, NULL)); } diff --git a/gtk/controller/namedpipe.h b/gtk/controller/namedpipe.h index e0e873b..59f5618 100644 --- a/gtk/controller/namedpipe.h +++ b/gtk/controller/namedpipe.h @@ -50,7 +50,9 @@ struct _SpiceNamedPipe GTypespice_named_pipe_get_type (void) G_GNUC_CONST; -SpiceNamedPipe * spice_named_pipe_new (const gchar *name, GError **error); +SpiceNamedPipe * spice_named_pipe_new (const gchar *name, + const gboolean is_server, + GError **error); void * spice_named_pipe_get_handle(SpiceNamedPipe *namedpipe); gboolean spice_named_pipe_close (SpiceNamedPipe *namedpipe, GError **error); diff --git a/gtk/controller/spice-controller-listener.c b/gtk/controller/spice-controller-listener.c index da1121e..202d516 100644 --- a/gtk/controller/spice-controller-listener.c +++ b/gtk/controller/spice-controller-listener.c @@ -89,7 +89,7 @@ spice_controller_listener_new (const gchar *address, GError **error) listener = G_OBJECT (spice_named_pipe_listener_new ()); -np = spice_named_pipe_new (addr, error); +np = spice_named_pipe_new (addr, TRUE, error); if (!np) { g_object_unref (listener); listener = NULL; diff --git a/gtk/controller/spice-foreign-menu-listener.c b/gtk/controller/spice-foreign-menu-listener.c index 8322a13..53e03e7 100644 --- a/gtk/controller/spice-foreign-menu-listener.c +++ b/gtk/controller/spice-foreign-menu-listener.c @@ -91,7 +91,7 @@ spice_foreign_menu_listener_new (const gchar *address, GError **error) listener = G_OBJECT (spice_named_pipe_listener_new ()); -np = spice_named_pipe_new (addr, error); +np = spice_named_pipe_new (addr, TRUE, error); if (!np) { g_object_unref (listener); listener = NULL; ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 v3 03/12] spicy: more informative presentation of usb devices in menu
ack, but a short comment on the detailed default format of spice_usb_device_get_description() will be nice. Uri Lublin wrote: --- gtk/spicy.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gtk/spicy.c b/gtk/spicy.c index 98a44d5..ba0aa4b 100644 --- a/gtk/spicy.c +++ b/gtk/spicy.c @@ -460,7 +460,7 @@ static void menu_cb_select_usb_devices(GtkAction *action, void *data) area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); usb_device_widget = spice_usb_device_widget_new(win-conn-session, -%s %s); +NULL); g_signal_connect(usb_device_widget, connect-failed, G_CALLBACK(usb_connect_failed), NULL); gtk_box_pack_start(GTK_BOX(area), usb_device_widget, TRUE, TRUE, 0); ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 v3 04/12] Add implementation of SpiceUsbDevice as a gobject (new files spice-usb-device*)
See notes below. I guess you defined it only for ref counting, otherwise you would have used simply a struct (similar to _SpiceUsbDevicePrivate) ? btw, why define Private and getters and not putting it all public? Is it the the right gobject-way? no shorter way to do it? (see spice_msg_in_ref(SpiceMsgIn *in) in spice-channel.c) Uri Lublin wrote: --- gtk/spice-usb-device-priv.h | 38 + gtk/spice-usb-device.c | 124 +++ gtk/spice-usb-device.h | 57 3 files changed, 219 insertions(+), 0 deletions(-) create mode 100644 gtk/spice-usb-device-priv.h create mode 100644 gtk/spice-usb-device.c create mode 100644 gtk/spice-usb-device.h diff --git a/gtk/spice-usb-device-priv.h b/gtk/spice-usb-device-priv.h new file mode 100644 index 000..80b3f5c --- /dev/null +++ b/gtk/spice-usb-device-priv.h @@ -0,0 +1,38 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + Copyright (C) 2011, 2012 Red Hat, Inc. + + Red Hat Authors: + Uri Lublin u...@redhat.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see http://www.gnu.org/licenses/. +*/ +#ifndef __SPICE_USB_DEVICE_PRIV_H__ +#define __SPICE_USB_DEVICE_PRIV_H__ + +#include libusb.h + +G_BEGIN_DECLS + +SpiceUsbDevice *spice_usb_device_new(void); +void spice_usb_device_set_info(SpiceUsbDevice *self, libusb_device *libdev); + +guint8 spice_usb_device_get_busnum(SpiceUsbDevice *device); +guint8 spice_usb_device_get_devaddr(SpiceUsbDevice *device); +guint16 spice_usb_device_get_vid(SpiceUsbDevice *device); +guint16 spice_usb_device_get_pid(SpiceUsbDevice *device); + +G_END_DECLS + +#endif /* __SPICE_USB_DEVICE_PRIV_H__ */ diff --git a/gtk/spice-usb-device.c b/gtk/spice-usb-device.c new file mode 100644 index 000..24ac1dd --- /dev/null +++ b/gtk/spice-usb-device.c @@ -0,0 +1,124 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + Copyright (C) 2011, 2012 Red Hat, Inc. + + Red Hat Authors: + Hans de Goede hdego...@redhat.com + Uri Lublin u...@redhat.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see http://www.gnu.org/licenses/. +*/ + +#include config.h + +#include glib-object.h +#include spice-usb-device.h +#include spice-usb-device-priv.h +#include usbutil.h +#include glib-compat.h + +#define SPICE_USB_DEVICE_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), SPICE_TYPE_USB_DEVICE, SpiceUsbDevicePrivate)) + +struct _SpiceUsbDevicePrivate { +guint8 bus; +guint8 addr; +guint16 vid; +guint16 pid; +}; + + +G_DEFINE_TYPE(SpiceUsbDevice, spice_usb_device, G_TYPE_OBJECT) + +/* -- */ + +static void spice_usb_device_init(SpiceUsbDevice *self) +{ +self-priv = SPICE_USB_DEVICE_GET_PRIVATE(self); +} + +static void spice_usb_device_class_init(SpiceUsbDeviceClass *klass) +{ +g_type_class_add_private(klass, sizeof(SpiceUsbDevicePrivate)); +} + +SpiceUsbDevice *spice_usb_device_new(void) +{ +GObject *obj; +SpiceUsbDevice *device; + +obj = g_object_new(SPICE_TYPE_USB_DEVICE, NULL); + why obj is good for? +device = SPICE_USB_DEVICE(obj); + +return device; +} + +void spice_usb_device_set_info(SpiceUsbDevice *self, libusb_device *libdev) +{ +SpiceUsbDevicePrivate *priv; + +g_return_if_fail(SPICE_IS_USB_DEVICE(self)); +priv = self-priv; + +g_warn_if_fail(libdev != NULL); + +#ifdef USE_USBREDIR isn't all of this is used only #ifdef USE_USBREDIR ? +if (libdev) { +struct libusb_device_descriptor desc; +int errcode; +const gchar *errstr; + +priv-bus = libusb_get_bus_number(libdev); +priv-addr = libusb_get_device_address(libdev); + +errcode = libusb_get_device_descriptor(libdev,
Re: [Spice-devel] [spice-gtk Win32 v3 06/12] Windows mingw: usb: configure.ac: do not require GUDEV for USBREDIR
ack, seems ok to me but can u pls remind me why needed to add $(GUDEV_CFLAGS/LIBS) ? Uri Lublin wrote: For windows GUDEV is not required For Linux GUDEV is checked as a part of USBREDIR block, but as a separate check. --- configure.ac| 15 ++- gtk/Makefile.am |2 ++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 09129b7..d928f1e 100644 --- a/configure.ac +++ b/configure.ac @@ -343,7 +343,7 @@ if test x$enable_usbredir = xno; then have_usbredir=no else PKG_CHECK_MODULES([USBREDIR], -[gudev-1.0 libusb-1.0 = 1.0.9 libusbredirhost = 0.4.2 libusbredirparser = 0.4], +[libusb-1.0 = 1.0.9 libusbredirhost = 0.4.2 libusbredirparser = 0.4], [have_usbredir=yes], [have_usbredir=no]) if test x$have_usbredir = xno test x$enable_usbredir = xyes; then @@ -352,6 +352,19 @@ else if test x$have_usbredir = xyes; then AC_DEFINE(USE_USBREDIR, [1], [Define if supporting usbredir proxying]) fi + + # Require gudev for non-windows + if test x$os_win32 = xno; then +PKG_CHECK_MODULES([GUDEV], + [gudev-1.0], + [have_gudev=yes], + [have_gudev=no]) + +if test x$have_usbredir = xyes test x$have_gudev = xno; then + AC_MSG_ERROR([usbredir requested but required gudev is not available]) +fi +AC_DEFINE(USE_GUDEV, [1], [Define if supporting gudev]) + fi fi AM_CONDITIONAL([WITH_USBREDIR], [test x$have_usbredir = xyes]) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index e79abae..0cf5952 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -82,6 +82,7 @@ SPICE_COMMON_CPPFLAGS = \ $(GST_CFLAGS) \ $(SMARTCARD_CFLAGS) \ $(USBREDIR_CFLAGS) \ + $(GUDEV_CFLAGS) \ $(NULL) AM_CPPFLAGS = \ @@ -179,6 +180,7 @@ libspice_client_glib_2_0_la_LIBADD = \ $(SASL_LIBS)\ $(SMARTCARD_LIBS) \ $(USBREDIR_LIBS)\ + $(GUDEV_LIBS) \ $(NULL) if WITH_POLKIT ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 v3 09/12] usb-device-manager: warn if a device to remove was not found
ack Uri Lublin wrote: Also changed a bit the warning text on device-add to differentiate the two. --- gtk/usb-device-manager.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index 8340335..d4740cf 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -602,7 +602,7 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager *self, libusb_free_device_list(dev_list, 1); if (!device) { -g_warning(Could not find USB device at busnum %d devaddr %d, +g_warning(Could not find USB device to add at busnum %d devaddr %d, bus, address); return; } @@ -646,8 +646,12 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager *self, break; } } -if (!device) + +if (!device) { +g_warning(Could not find USB device to remove at busnum %d devaddr %d, + bus, address); return; +} spice_usb_device_manager_disconnect_device(self, (SpiceUsbDevice *)device); ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 v3 05/12] Make SpiceUsbDevice a gobject, instead of a box for libusb_device
Seems great to me, but few comments below. Uri Lublin wrote: Note that this change may affect performance a bit, as we now need to look for the libusb_device if we need it. Likely it's negligible. --- gtk/Makefile.am |4 + gtk/channel-usbredir-priv.h |4 +- gtk/channel-usbredir.c| 46 +- gtk/map-file |7 ++ gtk/usb-device-manager-priv.h |3 + gtk/usb-device-manager.c | 194 + gtk/usb-device-manager.h |5 +- gtk/usb-device-widget.c |9 +-- spice-common |2 +- 9 files changed, 182 insertions(+), 92 deletions(-) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 0327d65..e79abae 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -228,6 +228,9 @@ libspice_client_glib_2_0_la_SOURCES = \ channel-usbredir-priv.h \ smartcard-manager.c \ smartcard-manager-priv.h\ + spice-usb-device.c \ + spice-usb-device.h \ + spice-usb-device-priv.h \ usb-device-manager.c\ usb-device-manager-priv.h \ usbutil.c \ @@ -266,6 +269,7 @@ libspice_client_glibinclude_HEADERS = \ channel-record.h\ channel-smartcard.h \ channel-usbredir.h \ + spice-usb-device.h \ usb-device-manager.h\ smartcard-manager.h \ $(NULL) diff --git a/gtk/channel-usbredir-priv.h b/gtk/channel-usbredir-priv.h index 5d28c79..e6cd538 100644 --- a/gtk/channel-usbredir-priv.h +++ b/gtk/channel-usbredir-priv.h @@ -37,7 +37,7 @@ void spice_usbredir_channel_set_context(SpiceUsbredirChannel *channel, (through spice_channel_connect()), before calling this. */ void spice_usbredir_channel_connect_device_async( SpiceUsbredirChannel *channel, -libusb_device*device, +SpiceUsbDevice *device, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -48,7 +48,7 @@ gboolean spice_usbredir_channel_connect_device_finish( void spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel); -libusb_device *spice_usbredir_channel_get_device(SpiceUsbredirChannel *channel); +SpiceUsbDevice *spice_usbredir_channel_get_device(SpiceUsbredirChannel *channel); void spice_usbredir_channel_get_guest_filter( SpiceUsbredirChannel *channel, diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c index 3d57152..63efb77 100644 --- a/gtk/channel-usbredir.c +++ b/gtk/channel-usbredir.c @@ -35,6 +35,7 @@ #include spice-client.h #include spice-common.h +#include spice-usb-device-priv.h #include spice-channel-priv.h #include glib-compat.h @@ -65,7 +66,7 @@ enum SpiceUsbredirChannelState { }; struct _SpiceUsbredirChannelPrivate { -libusb_device *device; +SpiceUsbDevice *device; struct usbredirhost *host; /* To catch usbredirhost error messages and report them as a GError */ GError **catch_error; @@ -211,6 +212,7 @@ static gboolean spice_usbredir_channel_open_device( SpiceUsbredirChannel *channel, GError **err) { SpiceUsbredirChannelPrivate *priv = channel-priv; +SpiceUsbDeviceManager *manager; libusb_device_handle *handle = NULL; int rc, status; @@ -220,7 +222,11 @@ static gboolean spice_usbredir_channel_open_device( #endif , FALSE); -rc = libusb_open(priv-device, handle); +manager = spice_usb_device_manager_get( +spice_channel_get_session(SPICE_CHANNEL(channel)), err); +if (!manager) +return FALSE; +rc = spice_usb_device_libusb_open(manager, priv-device, handle); if (rc != 0) { g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, Could not open usb device: %s [%i], @@ -236,10 +242,7 @@ static gboolean spice_usbredir_channel_open_device( return FALSE; } -if (!spice_usb_device_manager_start_event_listening( -spice_usb_device_manager_get( -spice_channel_get_session(SPICE_CHANNEL(channel)), NULL), -err)) { +if (!spice_usb_device_manager_start_event_listening(manager, err)) { usbredirhost_set_device(priv-host, NULL); return FALSE; } @@ -272,7 +275,7 @@ static void spice_usbredir_channel_open_acl_cb( } if (err) {
Re: [Spice-devel] [spice-gtk Win32 v3 07/12] Windows mingw: usb: implement GUdevDevice GUdevClient for windows
reviewed most of it before;) but added some comments for your changes below. Uri Lublin wrote: From: Arnon Gilboa agil...@redhat.com - Added win-usb-dev.[ch] - Added GUdevDevice and GUdevClient like classes - Added uevent signal based on WM_DEVICECHANGE With this patch usb-device-manager can work with little changes on windows too. --- gtk/Makefile.am | 13 ++ gtk/usb-device-manager.c |8 + gtk/win-usb-dev.c| 515 ++ gtk/win-usb-dev.h| 112 ++ 4 files changed, 648 insertions(+), 0 deletions(-) create mode 100644 gtk/win-usb-dev.c create mode 100644 gtk/win-usb-dev.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 0cf5952..4df3ee5 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -312,6 +312,19 @@ libspice_client_glib_2_0_la_SOURCES += coroutine_gthread.c libspice_client_glib_2_0_la_LIBADD += $(GTHREAD_LIBS) endif + +WIN_USB_FILES= \ + win-usb-dev.h \ + win-usb-dev.c \ + $(NULL) + +if OS_WIN32 +if WITH_USBREDIR +libspice_client_glib_2_0_la_SOURCES += \ + $(WIN_USB_FILES) +endif +endif + displaysrc = \ glib-compat.h \ display/edid.h \ diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index 4448a74..e4c8c32 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -28,7 +28,15 @@ #ifdef USE_USBREDIR #include errno.h #include libusb.h + +#if defined(USE_GUDEV) #include gudev/gudev.h +#elif defined(G_OS_WIN32) +#include win-usb-dev.h +#else +#warning Expecting one of G_OS_WIN32 and USE_GUDEV to be defined +#endif + #include channel-usbredir-priv.h #include usbredirhost.h #include usbutil.h diff --git a/gtk/win-usb-dev.c b/gtk/win-usb-dev.c new file mode 100644 index 000..b07d28b --- /dev/null +++ b/gtk/win-usb-dev.c @@ -0,0 +1,515 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + Copyright (C) 2012 Red Hat, Inc. + + Red Hat Authors: + Arnon Gilboa agil...@redhat.com + Uri Lublin u...@redhat.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see http://www.gnu.org/licenses/. +*/ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include windows.h +#include libusb.h +#include win-usb-dev.h +#include spice-marshal.h +#include spice-util.h +#include usbutil.h + +#define G_UDEV_CLIENT_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), G_UDEV_TYPE_CLIENT, GUdevClientPrivate)) + +struct _GUdevClientPrivate { +libusb_context *ctx; +gssize udev_list_size; +GList *udev_list; +HWND hwnd; +}; + +#define G_UDEV_CLIENT_WINCLASS_NAME TEXT(G_UDEV_CLIENT) + +static void g_udev_client_initable_iface_init(GInitableIface *iface); + +G_DEFINE_TYPE_WITH_CODE(GUdevClient, g_udev_client, G_TYPE_OBJECT, +G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, g_udev_client_initable_iface_init)); + + +typedef struct _GUdevDeviceInfo GUdevDeviceInfo; + +struct _GUdevDeviceInfo { +guint16 bus; +guint16 addr; +guint16 vid; +guint16 pid; +guint16 class; +gchar sclass[4]; +gchar sbus[4]; +gchar saddr[4]; +}; + +struct _GUdevDevicePrivate +{ +/* FixMe: move above fields to this structure and access them directly */ it will cleanup some code as well, remove the g_new0/g_free calls. you will also find it nice to merge get_usb_dev_info into g_udev_device_new, so it will be static GUdevDevice *g_udev_device_new(libusb_device *dev, GUdevDeviceInfo *udevinfo); +GUdevDeviceInfo *udevinfo; +}; + +G_DEFINE_TYPE(GUdevDevice, g_udev_device, G_TYPE_OBJECT) + + +enum +{ +UEVENT_SIGNAL, +LAST_SIGNAL, +}; + +static guint signals[LAST_SIGNAL] = { 0, }; +static GUdevClient *singleton = NULL; + +static GUdevDevice *g_udev_device_new(GUdevDeviceInfo *udevinfo); +static LRESULT CALLBACK wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +static gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *udevinfo); + +//uncomment to debug gudev device lists. +//#define DEBUG_GUDEV_DEVICE_LISTS + +#ifdef DEBUG_GUDEV_DEVICE_LISTS +static void g_udev_device_print_list(GList *l, const gchar *msg); +#else +static void g_udev_device_print_list(GList *l, const gchar *msg) {} +#endif +static void g_udev_device_print(GUdevDevice *udev
Re: [Spice-devel] [spice-gtk Win32 v3 10/12] win-usb-driver-install: add capability to remove (uninstall) a win usb driver
ack. I know this one;) Uri Lublin wrote: --- gtk/win-usb-driver-install.c | 69 +- gtk/win-usb-driver-install.h |6 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/gtk/win-usb-driver-install.c b/gtk/win-usb-driver-install.c index 9f4fdfc..7388923 100644 --- a/gtk/win-usb-driver-install.c +++ b/gtk/win-usb-driver-install.c @@ -113,7 +113,7 @@ static void win_usb_driver_async_result_set_cancelled(GSimpleAsyncResult *result { g_simple_async_result_set_error(result, G_IO_ERROR, G_IO_ERROR_CANCELLED, -Win USB driver installation cancelled); +Win USB driver un/installation cancelled); } static void win_usb_driver_cancelled_cb(GCancellable *cancellable, gpointer user_data) @@ -271,21 +271,13 @@ SpiceWinUsbDriver *spice_win_usb_driver_new(void) return SPICE_WIN_USB_DRIVER(obj); } -/** - * spice_win_usb_driver_install: - * Start libusb driver installation for @device - * - * A new NamedPipe is created for each request. - * - * Returns: TRUE if a request was sent to usbclerk - * FALSE upon failure to send a request. - */ -G_GNUC_INTERNAL -void spice_win_usb_driver_install(SpiceWinUsbDriver *self, - SpiceUsbDevice *device, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +static +void spice_win_usb_driver_op(SpiceWinUsbDriver *self, + SpiceUsbDevice *device, + guint16 op_type, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { guint16 vid, pid; SpiceNamedPipe *np; @@ -294,15 +286,13 @@ void spice_win_usb_driver_install(SpiceWinUsbDriver *self, GSimpleAsyncResult *result; SpiceWinUsbDriverPrivate *priv; -SPICE_DEBUG(Win usb driver installation started); - g_return_if_fail(SPICE_IS_WIN_USB_DRIVER(self)); g_return_if_fail(SPICE_IS_USB_DEVICE(device)); priv = self-priv; result = g_simple_async_result_new(G_OBJECT(self), callback, user_data, - spice_win_usb_driver_install); + spice_win_usb_driver_op); vid = spice_usb_device_get_vid(device); pid = spice_usb_device_get_pid(device); @@ -318,7 +308,7 @@ void spice_win_usb_driver_install(SpiceWinUsbDriver *self, npc = g_object_new(SPICE_TYPE_NAMED_PIPE_CONNECTION, namedpipe, np, NULL); priv-gios = G_IO_STREAM(npc); -if (!spice_win_usb_driver_send_request(self, USB_CLERK_DRIVER_INSTALL, +if (!spice_win_usb_driver_send_request(self, op_type, vid, pid, err)) { g_warning(failed to send a request to usbclerk %s, err-message); g_simple_async_result_take_error(result, err); @@ -345,6 +335,43 @@ void spice_win_usb_driver_install(SpiceWinUsbDriver *self, } + +/** + * spice_win_usb_driver_install: + * Start libusb driver installation for @device + * + * A new NamedPipe is created for each request. + * + * Returns: TRUE if a request was sent to usbclerk + * FALSE upon failure to send a request. + */ +G_GNUC_INTERNAL +void spice_win_usb_driver_install(SpiceWinUsbDriver *self, + SpiceUsbDevice *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ +SPICE_DEBUG(Win usb driver installation started); + +spice_win_usb_driver_op(self, device, USB_CLERK_DRIVER_INSTALL, cancellable, +callback, user_data); +} + +G_GNUC_INTERNAL +void spice_win_usb_driver_uninstall(SpiceWinUsbDriver *self, +SpiceUsbDevice *device, +GCancellable *cancellable, +GAsyncReadyCallback callback, +gpointer user_data) +{ +SPICE_DEBUG(Win usb driver uninstall operation started); + +spice_win_usb_driver_op(self, device, USB_CLERK_DRIVER_REMOVE, cancellable, +callback, user_data); +} + + /** * Returns: currently returns 0 (failure) and 1 (success) * possibly later we'll add error-codes @@ -357,7 +384,7 @@ gint spice_win_usb_driver_install_finish(SpiceWinUsbDriver *self, g_return_val_if_fail(SPICE_IS_WIN_USB_DRIVER(self), 0); g_return_val_if_fail(g_simple_async_result_is_valid(res, G_OBJECT(self), - spice_win_usb_driver_install), + spice_win_usb_driver_op), FALSE); if
Re: [Spice-devel] [spice-gtk Win32 v3 08/12] Windows mingw: usb: Dynamically install a libusb driver for USB devices
on a brief review, it seems ok, but won't a worker thread simplify the code and cut it by half? few minor comments below. Uri Lublin wrote: - Added win-usb-driver-install.[ch] - Added win-usb-clerk.h Operation (on Windows, spice-gtk point of view): - After some sanity checks, just before redir'ing a USB device a libusb driver needs to be installed (before libusb can open the device) - A connection (NamedPipe) is established with usb-clerk, a libusb driver installation service, and a request for driver installation is sent. - Installation status is asynchronously read from the pipe, and spice_usb_drv_install_finished() is called. - Upon a successful intallation, usbredir continues. Linux operation is not changed. --- gtk/Makefile.am | 11 ++ gtk/usb-device-manager.c | 143 +++- gtk/win-usb-clerk.h | 35 gtk/win-usb-driver-install.c | 379 ++ gtk/win-usb-driver-install.h | 98 +++ 5 files changed, 660 insertions(+), 6 deletions(-) create mode 100644 gtk/win-usb-clerk.h create mode 100644 gtk/win-usb-driver-install.c create mode 100644 gtk/win-usb-driver-install.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 4df3ee5..646b614 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -313,9 +313,20 @@ libspice_client_glib_2_0_la_LIBADD += $(GTHREAD_LIBS) endif +NAMED_PIPE_FILES = \ + controller/namedpipe.h \ + controller/namedpipe.c \ + controller/namedpipeconnection.c\ + controller/namedpipeconnection.h\ + $(NULL) + WIN_USB_FILES= \ win-usb-dev.h \ win-usb-dev.c \ + win-usb-clerk.h \ + win-usb-driver-install.h\ + win-usb-driver-install.c\ + $(NAMED_PIPE_FILES) \ $(NULL) if OS_WIN32 diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c index e4c8c32..8340335 100644 --- a/gtk/usb-device-manager.c +++ b/gtk/usb-device-manager.c @@ -33,6 +33,7 @@ #include gudev/gudev.h #elif defined(G_OS_WIN32) #include win-usb-dev.h +#include win-usb-driver-install.h #else #warning Expecting one of G_OS_WIN32 and USE_GUDEV to be defined #endif @@ -122,6 +123,14 @@ static void spice_usb_device_manager_uevent_cb(GUdevClient *client, gpointer user_data); static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager *self, GUdevDevice*udev); + +static void +_spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self, + SpiceUsbDevice *device, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + static libusb_device *spice_usb_device_find_libusb_device(SpiceUsbDeviceManager *self, SpiceUsbDevice *device); @@ -129,6 +138,12 @@ libusb_device *spice_usb_device_find_libusb_device(SpiceUsbDeviceManager *self, static void spice_usb_device_manager_initable_iface_init(GInitableIface *iface); +#ifdef G_OS_WIN32 +static void spice_usb_device_manager_drv_install_cb(GObject *gobject, +GAsyncResult *res, +gpointer user_data); +#endif + static guint signals[LAST_SIGNAL] = { 0, }; G_DEFINE_TYPE_WITH_CODE(SpiceUsbDeviceManager, spice_usb_device_manager, G_TYPE_OBJECT, @@ -604,7 +619,7 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager *self, spice_usb_device_manager_connect_device_async(self, device, NULL, spice_usb_device_manager_auto_connect_cb, - g_object_ref(device)); + device); } } @@ -669,6 +684,87 @@ static void spice_usb_device_manager_channel_connect_cb( g_object_unref(result); } +#ifdef G_OS_WIN32 + +typedef struct _UsbInstallCbInfo { +SpiceUsbDeviceManager *manager; +SpiceUsbDevice*device; +SpiceWinUsbDriver *installer; +GCancellable *cancellable; +GAsyncReadyCallback callback; +gpointer user_data; +} UsbInstallCbInfo; + +/** + * spice_usb_device_manager_drv_install_cb: + * @gobject: #SpiceWinUsbDriver in charge of installing the driver + * @res: #GAsyncResult of async win usb driver installation + * @user_data: #SpiceUsbDeviceManager requested the installation + * + * Called when an Windows libusb driver installation completed. + * + * If the driver installation was successful, continue with USB +
Re: [Spice-devel] [PATCH win-agent] desktop_layout: fix incorrect total_width/height
Nice catch. ACK. Marc-André Lureau wrote: When resizing desktop to best match, the agent fails to update it's current mode width/height and then incorrectly report different total_width/total_height than real screen dimensions, then scaling input incorrectly results in mouse cursor offset. https://bugzilla.redhat.com/show_bug.cgi?id=823019 --- vdagent/desktop_layout.cpp |5 + 1 file changed, 5 insertions(+) diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp index 7564cf6..3b474d1 100644 --- a/vdagent/desktop_layout.cpp +++ b/vdagent/desktop_layout.cpp @@ -298,6 +298,11 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo dev_mode-dmPosition.y = mode-_pos_y; dev_mode-dmFields |= DM_POSITION; } + +// update current DisplayMode (so mouse scaling works properly) +mode-_width = dev_mode-dmPelsWidth; +mode-_height = dev_mode-dmPelsHeight; + return true; } ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH win-agent] vdagent: reset clipboard event
Seems like the right hack. ACK. Marc-André Lureau wrote: Waiting for a Windows event will not last if it is already set. For example, the client may send clipboard_release() messages while we are not waiting in on_clipboard_request(), and this will SetEvent(clipboard_event) The following clipboard request will thus not wait for the data, resulting in an empty clipboard paste for the guest application. We could say there is fundamentally a race as there is no obvious way to know if a received message is related to the current request, but by reseting the event before waiting for new events to come, we at least clear the past events. --- vdagent/vdagent.cpp | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 9046476..eb6ffd4 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -918,13 +918,32 @@ void VDAgent::on_clipboard_request(UINT format) VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) { return; } + VDAgentClipboardRequest request = {type}; if (!write_message(VD_AGENT_CLIPBOARD_REQUEST, sizeof(request), request)) { return; } + +// next clipboard event will be considered a reply to this request +ResetEvent(_clipboard_event); + DWORD start_tick = GetTickCount(); -while (WaitForSingleObjectEx(_clipboard_event, 1000, TRUE) != WAIT_OBJECT_0 - GetTickCount() start_tick + VD_CLIPBOARD_TIMEOUT_MS); +do { +DWORD wait_result = WaitForSingleObjectEx(_clipboard_event, 1000, TRUE); + +switch (wait_result) { +case WAIT_OBJECT_0: +return; +case WAIT_IO_COMPLETION: +case WAIT_TIMEOUT: +break; +default: +vd_printf(Wait error (%d)\n, GetLastError()); +return; +} +} while (GetTickCount() start_tick + VD_CLIPBOARD_TIMEOUT_MS); + +vd_printf(wait timeout.. ); } void VDAgent::on_clipboard_release() ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] spice windows client
Hi Joris, see below. Enjoy, Arnon joris wrote: Dear list most likely I'm doing something stupid, but i searched all over google and cannot find the answer. I also looked through the docs on the spice website and still nothing. The problem however is quite simple. I downloaded the spice client (http://spice-space.org/download/binaries/spice-client-win32-0.6.3.zip) which I assumed was as installer. This program however fails to start either on win7-64 or winXP-32. In both cases the problem was that libcelt_0_5_1 was absent. To me it almost seems that what I downloaded was not an installer (that would include libcelt) but the actual runtime binary that should be applyed on top of a full installation. I guess somebody mistakenly deleted the relevant links for newer versions of the legacy windows client (spicec.exe), x64 builds and the windows spice libs (wspice). However, in addition to spicec.exe, the only thing you need is to extract to the same directory the file libcelt_0_5_1.dll from: http://spice-space.org/download/stable/wspice-x86_20110308.zip (I'll re-add the links today) I also install the guest tool (http://spice-space.org/download/binaries/spice-guest-tools-0.1.exe) but that did not improve the situation. This is for windows guest side, not windows client. Can someone indicate what I'm doing wrong? Do I need another package to install? Is there a separate windows installer for LibCelt that is required? I really hope someone can point me in the right direction. thanks for your time Joris ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH win-agent 9/9] Resize to arbitrary resolution
Alon Levy wrote: On Fri, May 11, 2012 at 06:39:18PM +0200, Marc-André Lureau wrote: Use QXL_ESCAPE_SET_CUSTOM_DISPLAY to update custom mode, and switch to it. --- vdagent/desktop_layout.cpp | 26 ++ 1 file changed, 26 insertions(+) diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp index 6e255fc..7564cf6 100644 --- a/vdagent/desktop_layout.cpp +++ b/vdagent/desktop_layout.cpp @@ -15,6 +15,7 @@ along with this program. If not, see http://www.gnu.org/licenses/. */ +#include spice/qxl_windows.h #include desktop_layout.h #include vdlog.h @@ -240,6 +241,8 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo { DWORD closest_diff = -1; DWORD best = -1; +QXLEscapeSetCustomDisplay custom; +HDC hdc = NULL; ZeroMemory(dev_mode, sizeof(DEVMODE)); dev_mode-dmSize = sizeof(DEVMODE); @@ -248,6 +251,29 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo dev_mode-dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; return true; } + +// Update custom resolution +custom.xres = mode-_width; +custom.yres = mode-_height; +custom.bpp = mode-_depth; +hdc = CreateDC(dev_name, NULL, NULL, NULL); +if (!hdc) { +vd_printf(failed to create DC: %s, dev_name); +} else { +int err = ExtEscape(hdc, QXL_ESCAPE_SET_CUSTOM_DISPLAY, +sizeof(QXLEscapeSetCustomDisplay), (LPCSTR)custom, 0, NULL); +if (err = 0) { +vd_printf(can't set custom display, perhaps an old driver); +} +DeleteDC(hdc); +} + +// force refresh mode table +DEVMODE tempDevMode; +ZeroMemory(tempDevMode, sizeof (tempDevMode)); +tempDevMode.dmSize = sizeof(DEVMODE); +EnumDisplaySettings(dev_name, 0xff, tempDevMode); Missing comment for 0xff (you mention this is used to refresh the modes list earlier). use ENUM_CURRENT_SETTINGS instead + //Find the closest size which will fit within the monitor for (DWORD i = 0; EnumDisplaySettings(dev_name, i, dev_mode); i++) { if (dev_mode-dmPelsWidth mode-_width || -- 1.7.10.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH win-agent 2/9] Revert Revert mingw: remove tMain use
breaks vs build 1LIBCMT.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 1Release\vdagent.exe : fatal error LNK1120: 1 unresolved externals we may patch vsproj || ifdef || add this line to vdagent.cpp: #pragma comment (linker, /ENTRY:mainCRTStartup) Marc-André Lureau wrote: This reverts commit 74af857e8e4a6240e9aac4a3d72aa0e5a443472b. --- vdagent/vdagent.cpp |2 +- vdservice/vdservice.cpp |6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 5cbe222..5ef0a18 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -1355,7 +1355,7 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA return 0; } -int APIENTRY _tWinMain(HINSTANCE instance, HINSTANCE prev_instance, LPTSTR cmd_line, int cmd_show) +int main(int argc,char **argv) { VDAgent* vdagent = VDAgent::get(); vdagent-run(); diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp index 4701f5a..9c057bb 100644 --- a/vdservice/vdservice.cpp +++ b/vdservice/vdservice.cpp @@ -1216,7 +1216,7 @@ void VDService::write_agent_control(uint32_t type, uint32_t opaque) } } -int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) +int main(int argc, char* argv[], char* envp[]) { bool success = false; @@ -1226,9 +1226,9 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) } VDService* vdservice = VDService::get(); if (argc 1) { -if (lstrcmpi(argv[1], TEXT(install)) == 0) { +if (strcmp(argv[1], install) == 0) { success = vdservice-install(); -} else if (lstrcmpi(argv[1], TEXT(uninstall)) == 0) { +} else if (strcmp(argv[1], uninstall) == 0) { success = vdservice-uninstall(); } else { printf(Use: vdservice install / uninstall\n); ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH win-agent 1/9] build-sys: fix autoreconf -vfi
(except #2) ACK series Acked-by: Arnon Gilboa agil...@redhat.com Marc-André Lureau wrote: --- configure.ac |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 77d5c25..28c9d23 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([1.11 subdir-objects no-dist-gzip dist-xz tar-ustar]) +AM_INIT_AUTOMAKE([1.11 foreign subdir-objects no-dist-gzip dist-xz tar-ustar]) AM_SILENT_RULES([yes]) ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [spice-gtk Win32 PATCH 3/7] Windows: add win-usb-dev.[ch]: implement GUdevDevice GUdevClient
Thanks for the review. Great comments which surely help a GObject/Gtk-dummy like myself ;) See below. Marc-André Lureau wrote: Hi On Mon, May 7, 2012 at 3:15 PM, Uri Lublin u...@redhat.com wrote: From: Arnon Gilboa agil...@redhat.com With this patch usb-device-manager can work with little change on windows too. -add uevent signal based on WM_DEVICECHANGE -add spice_usb_device_manager_set_window for setting winproc (which is needed for event registration) You should document any added public API. Can't we create a private/hidden window for that? Right, will be nicer cleaner. Will do that using Win32 API, seems ok? +WIN_USB_HDRS = \ + win-usb-dev.h \ + $(NULL) + Perhaps the header doesn't need to be conditionally excluded from the list of files. Also if it's not in the public API, it shouldn't be in the libspice_client_glibinclude_HEADERS. ok +WIN_USB_LIBS = $(GTK_LIBS) So the spice-glib lib will depend on Gtk? hmm.. I wish we can find something better. Right. The hidden window will remove this too. @@ -566,6 +586,7 @@ glib_introspection_files = \ channel-usbredir.c \ smartcard-manager.c \ usb-device-manager.c\ + $(WIN_USB_SRCS) \ Does that file need to be introspected? If it doesn't provide a public API, I guess not. right +#ifdef __linux__ #include gudev/gudev.h +#elif WIN32 +#include win-usb-dev.h +#endif We generally prefer the glib defines G_OS_WIN32 and G_OS_UNIX. In this case USE_GUDEV could also be more appropriate. ok +void spice_usb_device_manager_set_window(SpiceUsbDeviceManager *manager, GdkWindow *win) +{ +#ifdef WIN32 +g_udev_client_win_init(manager-priv-udev, manager, win); +#endif +} Please document that API, specify when it should be called, and what kind of window. Is it safe to be called multiple time, with NULL argument etc.. It needs to be annotated for introspection bindings to work correctly. will be done +gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *usbdev); Why is this function not static? sure +static GObject *g_udev_client_constructor(GType gtype, guint n_properties, + GObjectConstructParam *properties) +{ +GObject *obj = G_OBJECT_CLASS(g_udev_client_parent_class)-constructor( +gtype, n_properties, properties); +return obj; +} This doesn't need to be overriden. ok + +static void g_udev_client_init(GUdevClient *self) +{ +GUdevClientPrivate *priv; + +self-priv = priv = G_UDEV_CLIENT_GET_PRIVATE(self); +priv-usb_dev_mgr = NULL; +priv-dev_list = NULL; +priv-dev_list_size = 0; +priv-udevice_list = NULL; +priv-gdk_win = NULL; fields are already set to NULL after creation, you can get rid of this init() override. right +static void g_udev_client_finalize(GObject *gobject) +{ +GUdevClient *self = G_UDEV_CLIENT(gobject); +GUdevClientPrivate *priv = self-priv; + +if (priv-usb_dev_mgr || priv-gdk_win) { +gdk_window_remove_filter(priv-gdk_win, win_message_cb, priv-usb_dev_mgr); +g_list_free_full(priv-udevice_list, g_free); +libusb_free_device_list(priv-dev_list, 1); +libusb_exit(NULL); +} This looks prone to leaks if the finalize is called in an object intermediate state. Instead, it's recommended to check/free each pointer individually: if (priv-ptr) free_or_unref(priv-ptr) ... It's also sometime preferable to do all of this in _dispose() and set the pointers to NULL. This can solves some cyclic references, although perhaps not necessary here. What is the effect of calling libusb_exit(NULL); ? (it's already called by spice_usb_device_manager_finalize) ok. Will add context to init/exit. Is it right to use the context from SpiceUsbDeviceManagerPrivate ? + +gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *usbdev) +{ +if (!usbdev) { +return FALSE; +} There is a convenient function g_return_val_if_fail(usbdev != NULL, FALSE) for that. It will log if that condition happen too. right +if (libusb_get_device_descriptor(dev, usbdev-desc) 0) { +return FALSE; +} It might be worth to add some SPICE_DEBUG? sure +usbdev-dev = libusb_ref_device(dev); +sprintf(usbdev-sclass, %d, usbdev-desc.bDeviceClass); +sprintf(usbdev-sbus, %d, libusb_get_bus_number(dev)); +sprintf(usbdev-saddr, %d, libusb_get_device_address(dev)); +return TRUE; In general snprintf() is preferred. right +for (dev = (dev_change 0 ? devs : priv-dev_list); *dev !changed_dev; dev++) { +for (d = (dev_change 0 ? priv-dev_list : devs); *d *d != *dev
Re: [Spice-devel] Vdagent can not run
Hi, Seems like we are having again some issues with virtio-serial. Can you please send vdservice.log as well? 10x, Arnon wangfeng wangfeng wrote: Hi, I have installed vdservice successfully. But after I restart the windows7 guest, vdagent can not run ,and vdservice stoped. When I start vdservice it says The RHEV Spice Agent on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs . What is the problem? Thanks! Here is vdagentlog: 904::INFO::2012-04-25 16:27:22,009::VDAgent::run::***Agent started in session 1*** 904::INFO::2012-04-25 16:27:22,009::log_version::1.1.0.1009 904::INFO::2012-04-25 16:27:22,009::DesktopLayout::consistent_displays::#qxls 1 #others 0 904::INFO::2012-04-25 16:27:22,009::VDAgent::connect_pipe::Connected to service pipe 904::INFO::2012-04-25 16:27:22,009::VDAgent::send_announce_capabilities::Sending capabilities: 904::INFO::2012-04-25 16:27:22,009::VDAgent::send_announce_capabilities::37 904::INFO::2012-04-25 16:27:22,009::VDAgent::input_desktop_message_loop::Desktop: Default 904::INFO::2012-04-25 16:27:22,009::VDAgent::input_desktop_message_loop::First display setting 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::load::loading display setting 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::reload_from_registry::explorer pid 1276 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::reload_wallpaper:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_wallpaper::wallpaper wasn't disabled 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_font_smoothing:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_font_smoothing::font smoothing value didn't change 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_animation:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_win_animation:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_win_animation::reload window animation: success 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_ui_effects:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::reload_ui_effects::UserPreferencesMask = 80073e9e 12 904::INFO::2012-04-25 16:27:22,087::VDAgent::read_completion::vdservice disconnected (109) 904::INFO::2012-04-25 16:27:22,087::VDAgent::run::Agent stopped ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Vdagent can not run
Seems like a virtio-serial driver issue. I have the similar behavior here with new driver. As you can see in your log, vdservice fails to open virtio-serial. Look in qemu for a line such as: qemu-system-x86_64: virtio-serial-bus: Unexpected port id 42456816 for device virtio-serial-bus.0 CC'ed the maintainer of the driver. Vadim/Yan, any insight? 10x, Arnon wangfeng wangfeng wrote: Thank you very much. Here is vdservice.log: 4048::INFO::2012-04-25 17:16:15,932::VDService::main::***Service started*** 4048::INFO::2012-04-25 17:16:15,932::log_version::1.1.0.1009 4048::INFO::2012-04-25 17:16:15,932::VDService::launch_agent::Wait for vdagent to connect 4048::INFO::2012-04-25 17:16:15,963::VDService::launch_agent::Pipe connected by vdagent 4048::INFO::2012-04-25 17:16:15,963::VirtioVDIPort::init::CreateFile() \ failed: 2 4048::INFO::2012-04-25 17:16:15,963::PCIVDIPort::init::CreateFile() failed: 2 4048::INFO::2012-04-25 17:16:15,963::VDService::execute::Failed to create VDIPort instance 2012/4/25 Arnon Gilboa agil...@redhat.com Hi, Seems like we are having again some issues with virtio-serial. Can you please send vdservice.log as well? 10x, Arnon wangfeng wangfeng wrote: Hi, I have installed vdservice successfully. But after I restart the windows7 guest, vdagent can not run ,and vdservice stoped. When I start vdservice it says The RHEV Spice Agent on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs . What is the problem? Thanks! Here is vdagentlog: 904::INFO::2012-04-25 16:27:22,009::VDAgent::run::*Agent started in session 1*** 904::INFO::2012-04-25 16:27:22,009::log_version::1.**1.0.1009 904::INFO::2012-04-25 16:27:22,009::DesktopLayout::**consistent_displays::#qxls 1 #others 0 904::INFO::2012-04-25 16:27:22,009::VDAgent::**connect_pipe::Connected to service pipe 904::INFO::2012-04-25 16:27:22,009::VDAgent::send_**announce_capabilities::Sending capabilities: 904::INFO::2012-04-25 16:27:22,009::VDAgent::send_** announce_capabilities::37 904::INFO::2012-04-25 16:27:22,009::VDAgent::input_**desktop_message_loop::Desktop: Default 904::INFO::2012-04-25 16:27:22,009::VDAgent::input_**desktop_message_loop::First display setting 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::**load::loading display setting 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::**reload_from_registry::explorer pid 1276 904::INFO::2012-04-25 16:27:22,009::DisplaySetting::**reload_wallpaper:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_wallpaper::wallpaper wasn't disabled 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::** reload_font_smoothing:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_font_smoothing::font smoothing value didn't change 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_animation:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::** reload_win_animation:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_win_animation::reload window animation: success 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_ui_effects:: 904::INFO::2012-04-25 16:27:22,024::DisplaySetting::**reload_ui_effects::**UserPreferencesMask = 80073e9e 12 904::INFO::2012-04-25 16:27:22,087::VDAgent::read_**completion::vdservice disconnected (109) 904::INFO::2012-04-25 16:27:22,087::VDAgent::run::**Agent stopped --**--** __**_ Spice-devel mailing list Spice-devel@lists.freedesktop.**org Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/**mailman/listinfo/spice-develhttp://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] spice libraries for windows client
Christophe Fergeau wrote: Hi, On Sun, Apr 15, 2012 at 12:24:38PM +0300, Arnon Gilboa wrote: will be nice to keep latest x86 x64 wspice zips on the new dl page. otherwise, no way to run the legacy spicec on windows. These would be http://spice-space.org/download/stable/wspice-x86_20110308.zip and http://spice-space.org/download/stable/wspice-x64_20110308.zip ? Christophe ack ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] spice libraries for windows client
Christophe Fergeau wrote: Hey, On Thu, Apr 05, 2012 at 02:40:53PM +, Dylan Denney wrote: What happened to the windows spice library download? without it the spice client will not run. Ah, I recently reorganized the download page and thought they were not needed. The old page is at http://spice-space.org/download-old.html Can you let me know which zip file exactly you need? Thanks, Christophe will be nice to keep latest x86 x64 wspice zips on the new dl page. otherwise, no way to run the legacy spicec on windows. 10x, Arnon ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Spice is breaking in 32 bits hosts
AFAIK, Spice server works only on x86_64, because it is dependent on 64-bit atomic operations. There is no known plan to port it to other architecture. See http://www.spice-space.org/page/FAQ. Fabiano Fidêncio wrote: Guys, I've been trouble using spice-protocol/spice/qemu from git, in a 32 bits host. Could somone take a look in this issue? fidencio@sasha ~/src/spice $ sudo LD_LIBRARY_PATH=/home/fidencio/dev/lib gdb --args /home/fidencio/dev/bin/qemu-system-i386 -enable-kvm -m 1024 -device e1000,vlan=0 -net tap,script=/home/fidencio/dev/etc/qemu-ifup -vga qxl /home/fidencio/libvirt/images/fedora16-i686.img Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i686-redhat-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/fidencio/dev/bin/qemu-system-i386...(no debugging symbols found)...done. (gdb) r Starting program: /home/fidencio/dev/bin/qemu-system-i386 -enable-kvm -m 1024 -device e1000,vlan=0 -net tap,script=/home/fidencio/dev/etc/qemu-ifup -vga qxl /home/fidencio/libvirt/images/fedora16-i686.img [Thread debugging using libthread_db enabled] Using host libthread_db library /lib/libthread_db.so.1. Detaching after fork from child process 7306. Bringing up interface tap0... Done Adding interface tap0 to bridge br0... Done [New Thread 0xb7edab40 (LWP 7316)] [New Thread 0xb76d9b40 (LWP 7317)] do_spice_init: starting 0.10.1 spice_server_add_interface: SPICE_INTERFACE_QXL [New Thread 0xb1b8ab40 (LWP 7318)] red_worker_main: begin display_channel_create: create display channel cursor_channel_create: create cursor channel id 0, group 0, virt start 0, virt end , generation 0, delta 0 get_virt: panic: slot_id too big, addr=b1b8b008 Program received signal SIGABRT, Aborted. [Switching to Thread 0xb1b8ab40 (LWP 7318)] 0x00133416 in __kernel_vsyscall () (gdb) bt #0 0x00133416 in __kernel_vsyscall () #1 0x0077d98f in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #2 0x0077f2d5 in __GI_abort () at abort.c:91 #3 0x00634de0 in get_virt (info=0xb1b87800, addr=2981670920, add_size= 1228800, group_id=0) at red_memslots.c:110 #4 0x0064324a in dev_create_primary_surface (worker=0xb1a66030, surface_id=optimized out, surface=...) at red_worker.c:10417 #5 0x006433fe in handle_dev_create_primary_surface (opaque=0xb1a66030, payload=0xb1200468) at red_worker.c:10443 #6 0x006322bc in dispatcher_handle_single_read (dispatcher=0x80a82cd0) at dispatcher.c:120 #7 dispatcher_handle_recv_read (dispatcher=0x80a82cd0) at dispatcher.c:143 #8 0x00637636 in handle_dev_input (fd=20, event=1, opaque=0xb1a66030) at red_worker.c:11032 #9 0x0064d965 in red_worker_main (arg=0xbfffeecc) at red_worker.c:11163 #10 0x004c7cd3 in start_thread (arg=0xb1b8ab40) at pthread_create.c:309 #11 0x00841a2e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:133 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Can USB redirection be enabled on windows client?
spice-gtk windows client support for USB redir is still under development. Patches will be posted very soon. The old spicec client for windows supports USB redir using Incentives Pro's product. Arnon Andrew Osborne wrote: Works with Fedora 16 and WinXp as client Andrew On 17 Mar 2012, at 18:03, Dominique Rodrigues dominique.rodrig...@nanocloud.com wrote: If I remember well (TBC by spice developers), USB redirection works now only for a Linux client and should be a feature for Microsoft operating systems (no idea when). Dominique Rodrigues nanologo_small.png Le 17/03/2012 18:48, wangsuyi640 a écrit : Hi all: Can USB redirection be enabled on windows client of spice? There is no option for me to choose set USB redirection on the windows client. Can anyone help me ? My client OS is windows XP 3. Thanks a lot! Yours Sinerely! suyi ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel dominique_rodrigues.vcf ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] Problem about qxl and vmc
wangfeng wangfeng wrote: Hi, I have created a Win7 VM by libvirt. Then I installed only qxl driver but no virtio-serial driver, and vdservice is also not running. But the mouse can move smoothly without SHIFT+F12. Isn't this vdagent's function? After that I installed virtio-serial driver, vdservice and vdagent. The wallpaper was disabled. So what's the problem and who control the mouse ? Thank you. Wang. Hi Wang, vdservice/vdagent cannot run without virtio-serial driver installed. Client mouse mode (no capture/SHIFT+F12 needed) has also legacy support for single monitor when qemu is run with -device usb-tablet. Wallpaper was disabled by vdagent (see DisplaySetting::disable_wallpaper::disable wallpaper: success). Any chance the client was launched with --disable-effects? does mouse keeps working correctly in client mode? The vdagent log says: *164::INFO::2012-03-06 16:43:33,302::VDAgent::run::***Agent started in session 1 * * *164::INFO::2012-03-06 16:43:33,302::log_version::1.1.0.1009* * * *164::INFO::2012-03-06 16:43:33,302::DesktopLayout::consistent_displays::#qxls 1 #others 0* * * *164::INFO::2012-03-06 16:43:33,302::VDAgent::connect_pipe::Connected to service pipe* * * *164::INFO::2012-03-06 16:43:33,302::VDAgent::send_announce_capabilities::Sending capabilities:* * * *164::INFO::2012-03-06 16:43:33,302::VDAgent::send_announce_capabilities::37 * * * *164::INFO::2012-03-06 16:43:33,302::VDAgent::input_desktop_message_loop::Desktop: Default* * * *164::INFO::2012-03-06 16:43:33,302::VDAgent::input_desktop_message_loop::First display setting* * * *164::INFO::2012-03-06 16:43:33,302::DisplaySetting::load::loading display setting* * * *164::INFO::2012-03-06 16:43:33,302::DisplaySetting::load::open registry key: fail 2* * * *164::INFO::2012-03-06 16:43:33,317::VDAgent::handle_announce_capabilities::Got capabilities (1)* * * *164::INFO::2012-03-06 16:43:33,317::VDAgent::handle_announce_capabilities::77* * * *164::INFO::2012-03-06 16:43:33,317::VDAgent::send_announce_capabilities::Sending capabilities:* * * *164::INFO::2012-03-06 16:43:33,317::VDAgent::send_announce_capabilities::37 * * * *164::INFO::2012-03-06 16:43:33,333::VDAgent::handle_announce_capabilities::Got capabilities (1)* * * *164::INFO::2012-03-06 16:43:33,333::VDAgent::handle_announce_capabilities::77* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::set::setting display options* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_from_registry::explorer pid 1240* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_wallpaper::* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_wallpaper::wallpaper wasn't disabled* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_font_smoothing:: * * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_font_smoothing::font smoothing value didn't change* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_animation::* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_win_animation::* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_win_animation::reload window animation: success* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_ui_effects::* * * *164::INFO::2012-03-06 16:43:33,333::DisplaySetting::reload_ui_effects::UserPreferencesMask = 80073e9e 12* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::set::setting display options* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::disable_wallpaper::disable wallpaper: success* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_from_registry::explorer pid 1240* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_font_smoothing:: * * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_font_smoothing::font smoothing value didn't change* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_animation::* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_win_animation::* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_win_animation::reload window animation: success* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_ui_effects::* * * *164::INFO::2012-03-06 16:43:33,395::DisplaySetting::reload_ui_effects::UserPreferencesMask = 80073e9e 12* * * *164::INFO::2012-03-06 16:43:33,426::DesktopLayout::consistent_displays::#qxls 1 #others 0* * * *164::INFO::2012-03-06 16:43:33,442::DesktopLayout::set_displays::No suitable mode found for display \\.\DISPLAY1* * * * * ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel