aboutsummaryrefslogtreecommitdiff
path: root/qemu-ga.c
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2012-01-20 19:01:30 -0600
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-02-23 15:43:49 -0600
commit7868e26e5930f49ca942311885776b938dcf3b77 (patch)
treed1fad8cd6f57209d7812d55dd5fe13d2460a05df /qemu-ga.c
parentd8ca685acbd06b5cccd9fcd7866ded1f453b8311 (diff)
qemu-ga: add initial win32 support
This adds a win32 channel implementation that makes qemu-ga functional on Windows using virtio-serial (unix-listen/isa-serial not currently implemented). Unlike with the posix implementation, we do not use GIOChannel for the following reasons: - glib calls stat() on an fd to check whether S_IFCHR is set, which is the case for virtio-serial on win32. Because of that, a one-time check to determine whether the channel is readable is done by making a call to PeekConsoleInput(), which reports the underlying handle is not a valid console handle, and thus we can never read from the channel. - if one goes as far as to "trick" glib into thinking it is a normal file descripter, the buffering is done in such a way that data written to the output stream will subsequently result in that same data being read back as if it were input, causing an error loop. furthermore, a forced flush of the channel only moves the data into a secondary buffer managed by glib, so there's no way to prevent output from getting read back as input. The implementation here ties into the glib main loop by implementing a custom GSource that continually submits asynchronous/overlapped I/O to fill an GAChannel-managed read buffer, and tells glib to poll the corresponding event handle for a completion whenever there is no data/RPC in the read buffer to notify the main application about.
Diffstat (limited to 'qemu-ga.c')
-rw-r--r--qemu-ga.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/qemu-ga.c b/qemu-ga.c
index 93ebc3e471..8e517b5513 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -30,7 +30,11 @@
#include "qapi/qmp-core.h"
#include "qga/channel.h"
+#ifndef _WIN32
#define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
+#else
+#define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
+#endif
#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
struct GAState {