summary refs log tree commit diff stats
path: root/qga/channel-win32.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-02-25 12:30:01 +0000
committerPeter Maydell <peter.maydell@linaro.org>2014-02-25 12:30:01 +0000
commit0459650d94d18218808fcabc8c3227d2ee99af39 (patch)
tree89b1f02e7e4784c444faf91506ca7fcfd8bb7e7b /qga/channel-win32.c
parent05fd3bf2a1c9fc26414d3cf608732c40d0d9eb23 (diff)
parenta749f42da5129bbfadea6926964d9a213ed4bc5f (diff)
downloadfocaccia-qemu-0459650d94d18218808fcabc8c3227d2ee99af39.tar.gz
focaccia-qemu-0459650d94d18218808fcabc8c3227d2ee99af39.zip
Merge remote-tracking branch 'remotes/mdroth/qga-pull-2014-02-24' into staging
* remotes/mdroth/qga-pull-2014-02-24:
  qemu-ga: isa-serial support on Windows
  qga: Fix memory allocation pasto
  qga: Don't require 'time' argument in guest-set-time command
  qga: vss-win32: Fix interference with snapshot deletion by other VSS request
  qga: vss-win32: Fix interference with snapshot creation by other VSS requesters
  qga: vss-win32: Use NULL as an invalid pointer for OpenEvent and CreateEvent

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qga/channel-win32.c')
-rw-r--r--qga/channel-win32.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 8a303f35ec..0d5e5f511f 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -287,12 +287,22 @@ GIOStatus ga_channel_write_all(GAChannel *c, const char *buf, size_t size)
 static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
                                 const gchar *path)
 {
-    if (method != GA_CHANNEL_VIRTIO_SERIAL) {
+    COMMTIMEOUTS comTimeOut = {0};
+    gchar newpath[MAXPATHLEN] = {0};
+    comTimeOut.ReadIntervalTimeout = 1;
+
+    if (method != GA_CHANNEL_VIRTIO_SERIAL && method != GA_CHANNEL_ISA_SERIAL) {
         g_critical("unsupported communication method");
         return false;
     }
 
-    c->handle = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
+    if (method == GA_CHANNEL_ISA_SERIAL){
+        snprintf(newpath, sizeof(newpath), "\\\\.\\%s", path);
+    }else {
+        g_strlcpy(newpath, path, sizeof(newpath));
+    }
+
+    c->handle = CreateFile(newpath, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                            OPEN_EXISTING,
                            FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
     if (c->handle == INVALID_HANDLE_VALUE) {
@@ -300,6 +310,12 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
         return false;
     }
 
+    if (method == GA_CHANNEL_ISA_SERIAL && !SetCommTimeouts(c->handle,&comTimeOut)) {
+        g_critical("error setting timeout for com port: %lu",GetLastError());
+        CloseHandle(c->handle);
+        return false;
+    }
+
     return true;
 }