diff options
Diffstat (limited to 'vdservice/vdi_port.cpp')
-rw-r--r-- | vdservice/vdi_port.cpp | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/vdservice/vdi_port.cpp b/vdservice/vdi_port.cpp index 8af95b2..e36ff86 100644 --- a/vdservice/vdi_port.cpp +++ b/vdservice/vdi_port.cpp @@ -15,23 +15,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <windows.h> -#include <setupapi.h> #include "stdio.h" #include "vdi_port.h" #include "vdlog.h" -const GUID GUID_VIOSERIAL_PORT = - {0x6fde7521, 0x1b65, 0x48ae, 0xb6, 0x28, 0x80, 0xbe, 0x62, 0x1, 0x60, 0x26}; +#define VIOSERIAL_PORT_PATH L"\\\\.\\Global\\com.redhat.spice.0" // Current limitation of virtio-serial windows driver (RHBZ 617000) #define VIOSERIAL_PORT_MAX_WRITE_BYTES 2048 -// Retry initial connection to device. On boot when vdservice is started the device is -// not immediately available (takes 2 seconds, 30 is for extreme load). -#define VIOSERIAL_PORT_DEVICE_OPEN_MAX_RETRIES 30 -#define VIOSERIAL_PORT_DEVICE_OPEN_RETRY_INTERVAL_MS 1000 - #define MIN(a, b) ((a) > (b) ? (b) : (a)) VDIPort* VDIPort::_singleton; @@ -59,61 +51,9 @@ VDIPort::~VDIPort() } } -//Based on device.cpp from vioserial test app -//FIXME: remove this call & lib? -PTCHAR get_device_path(IN LPGUID interface_guid) -{ - HDEVINFO dev_info; - SP_DEVICE_INTERFACE_DATA dev_interface; - PSP_DEVICE_INTERFACE_DETAIL_DATA dev_interface_detail = NULL; - ULONG len, req_len = 0; - - dev_info = SetupDiGetClassDevs(interface_guid, NULL, NULL, - DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); - if (dev_info == INVALID_HANDLE_VALUE) { - vd_printf("Cannot get class devices"); - return NULL; - } - dev_interface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - if (!SetupDiEnumDeviceInterfaces(dev_info, 0, interface_guid, 0, &dev_interface)) { - vd_printf("Cannot get enumerate device interfaces"); - SetupDiDestroyDeviceInfoList(dev_info); - return NULL; - } - SetupDiGetDeviceInterfaceDetail(dev_info, &dev_interface, NULL, 0, &req_len, NULL); - dev_interface_detail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LMEM_FIXED, req_len); - if (dev_interface_detail == NULL) { - vd_printf("Cannot allocate memory"); - SetupDiDestroyDeviceInfoList(dev_info); - return NULL; - } - dev_interface_detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - len = req_len; - if (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_interface, dev_interface_detail, len, - &req_len, NULL)) { - vd_printf("Cannot get device interface details"); - SetupDiDestroyDeviceInfoList(dev_info); - LocalFree(dev_interface_detail); - return NULL; - } - return dev_interface_detail->DevicePath; -} - bool VDIPort::init() { - PTCHAR path = NULL; - - for (int retry = 0; retry < VIOSERIAL_PORT_DEVICE_OPEN_MAX_RETRIES && path == NULL; retry++) { - if (path = get_device_path((LPGUID)&GUID_VIOSERIAL_PORT)) { - break; - } - Sleep(VIOSERIAL_PORT_DEVICE_OPEN_RETRY_INTERVAL_MS); - } - if (path == NULL) { - vd_printf("GetDevicePath failed - device/driver missing?"); - return false; - } - _handle = CreateFile(path, GENERIC_READ | GENERIC_WRITE , 0, NULL, + _handle = CreateFile(VIOSERIAL_PORT_PATH, GENERIC_READ | GENERIC_WRITE , 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (_handle == INVALID_HANDLE_VALUE) { vd_printf("CreateFile() failed: %u", GetLastError()); |