From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@amazon.com, mprivozn@redhat.com, qemu-stable@nongnu.org,
armbru@redhat.com, tomoki.sekiyama@hds.com, mmishael@redhat.com
Subject: [Qemu-devel] [PATCH 6/6] qemu-ga: isa-serial support on Windows
Date: Sun, 23 Feb 2014 19:21:13 -0600 [thread overview]
Message-ID: <1393204873-13367-7-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1393204873-13367-1-git-send-email-mdroth@linux.vnet.ibm.com>
From: Miki Mishael <mmishael@redhat.com>
Add support for isa-serial method for qemu-ga on Windows,
Added -p command line parameter for serial port name
specification, e.g. "-p COM15".
Signed-off-by: Miki Mishael <mmishael@redhat.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
*added default isa-serial path to help output
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/channel-win32.c | 20 ++++++++++++++++++--
qga/main.c | 17 +++++++++++++----
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 8a303f3..0d5e5f5 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;
}
diff --git a/qga/main.c b/qga/main.c
index c58b26a..cfca291 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -47,9 +47,11 @@
#ifndef _WIN32
#define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
#define QGA_STATE_RELATIVE_DIR "run"
+#define QGA_SERIAL_PATH_DEFAULT "/dev/ttyS0"
#else
#define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
#define QGA_STATE_RELATIVE_DIR "qemu-ga"
+#define QGA_SERIAL_PATH_DEFAULT "COM1"
#endif
#ifdef CONFIG_FSFREEZE
#define QGA_FSFREEZE_HOOK_DEFAULT CONFIG_QEMU_CONFDIR "/fsfreeze-hook"
@@ -189,6 +191,8 @@ static void usage(const char *cmd)
" -m, --method transport method: one of unix-listen, virtio-serial, or\n"
" isa-serial (virtio-serial is the default)\n"
" -p, --path device/socket path (the default for virtio-serial is:\n"
+" %s,\n"
+" the default for isa-serial is:\n"
" %s)\n"
" -l, --logfile set logfile path, logs to stderr by default\n"
" -f, --pidfile specify pidfile (default is %s)\n"
@@ -215,7 +219,8 @@ static void usage(const char *cmd)
" -h, --help display this help and exit\n"
"\n"
"Report bugs to <mdroth@linux.vnet.ibm.com>\n"
- , cmd, QEMU_VERSION, QGA_VIRTIO_PATH_DEFAULT, dfl_pathnames.pidfile,
+ , cmd, QEMU_VERSION, QGA_VIRTIO_PATH_DEFAULT, QGA_SERIAL_PATH_DEFAULT,
+ dfl_pathnames.pidfile,
#ifdef CONFIG_FSFREEZE
QGA_FSFREEZE_HOOK_DEFAULT,
#endif
@@ -659,12 +664,16 @@ static gboolean channel_init(GAState *s, const gchar *method, const gchar *path)
}
if (path == NULL) {
- if (strcmp(method, "virtio-serial") != 0) {
+ if (strcmp(method, "virtio-serial") == 0 ) {
+ /* try the default path for the virtio-serial port */
+ path = QGA_VIRTIO_PATH_DEFAULT;
+ } else if (strcmp(method, "isa-serial") == 0){
+ /* try the default path for the serial port - COM1 */
+ path = QGA_SERIAL_PATH_DEFAULT;
+ } else {
g_critical("must specify a path for this channel");
return false;
}
- /* try the default path for the virtio-serial port */
- path = QGA_VIRTIO_PATH_DEFAULT;
}
if (strcmp(method, "virtio-serial") == 0) {
--
1.7.9.5
next prev parent reply other threads:[~2014-02-24 1:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 1:21 [Qemu-devel] [PULL 0/6] qemu-ga: various fixes, and serial support for w32 Michael Roth
2014-02-24 1:21 ` [Qemu-devel] [PATCH 1/6] qga: vss-win32: Use NULL as an invalid pointer for OpenEvent and CreateEvent Michael Roth
2014-02-24 1:21 ` [Qemu-devel] [PATCH 2/6] qga: vss-win32: Fix interference with snapshot creation by other VSS requesters Michael Roth
2014-02-24 1:21 ` [Qemu-devel] [PATCH 3/6] qga: vss-win32: Fix interference with snapshot deletion by other VSS request Michael Roth
2014-02-24 1:21 ` [Qemu-devel] [PATCH 4/6] qga: Don't require 'time' argument in guest-set-time command Michael Roth
2014-02-24 1:21 ` [Qemu-devel] [PATCH 5/6] qga: Fix memory allocation pasto Michael Roth
2014-02-24 1:21 ` Michael Roth [this message]
2014-02-25 12:57 ` [Qemu-devel] [PULL 0/6] qemu-ga: various fixes, and serial support for w32 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393204873-13367-7-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=mmishael@redhat.com \
--cc=mprivozn@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=tomoki.sekiyama@hds.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).