From patchwork Sun Jan 5 17:18:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miki Mishael X-Patchwork-Id: 306982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E66B12C0091 for ; Mon, 6 Jan 2014 04:19:40 +1100 (EST) Received: from localhost ([::1]:58711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzrMP-0004fu-PU for incoming@patchwork.ozlabs.org; Sun, 05 Jan 2014 12:19:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzrM5-0004fa-Dh for qemu-devel@nongnu.org; Sun, 05 Jan 2014 12:19:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VzrLz-0001Zb-Dt for qemu-devel@nongnu.org; Sun, 05 Jan 2014 12:19:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzrLz-0001ZW-5m for qemu-devel@nongnu.org; Sun, 05 Jan 2014 12:19:11 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s05HJ7O3019079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 5 Jan 2014 12:19:07 -0500 Received: from rebark.localdomain (vpn-200-217.tlv.redhat.com [10.35.200.217]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s05HJ31A026352; Sun, 5 Jan 2014 12:19:04 -0500 From: Miki Mishael To: qemu-devel@nongnu.org Date: Sun, 5 Jan 2014 12:18:51 -0500 Message-Id: <1388942331-2459-1-git-send-email-mmishael@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Yan Vugenfirer , Michael Roth , Adam Litke , Ronen Hod , Anthony Liguori , Dmitry Fleytman , Miki Mishael Subject: [Qemu-devel] [PATCH] qemu-ga: isa-serial support on Windows X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Dmitry Fleytman --- qga/channel-win32.c | 27 +++++++++++++++++++++++++-- qga/main.c | 14 +++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/qga/channel-win32.c b/qga/channel-win32.c index 8a303f3..fd42460 100644 --- a/qga/channel-win32.c +++ b/qga/channel-win32.c @@ -284,15 +284,32 @@ GIOStatus ga_channel_write_all(GAChannel *c, const char *buf, size_t size) return status; } +static void ga_serial_path_correction( gchar* newpath, const gchar *path, size_t maxdestlen) +{ + gchar *prefix = "\\\\.\\"; + g_strlcpy(newpath, prefix, maxdestlen); + g_strlcat(newpath, path, maxdestlen); +} + 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){ + ga_serial_path_correction(newpath, path, sizeof(newpath)); + }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 +317,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 SetCommTimeouts: %d",GetLastError()); + CloseHandle(c->handle); + return false; + } + return true; } diff --git a/qga/main.c b/qga/main.c index c58b26a..ad21061 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 "" #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" @@ -659,12 +661,18 @@ 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) {