From patchwork Thu Sep 3 12:53:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 32884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4318AB70B0 for ; Thu, 3 Sep 2009 23:02:42 +1000 (EST) Received: from localhost ([127.0.0.1]:45976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjBxV-0003F9-Pu for incoming@patchwork.ozlabs.org; Thu, 03 Sep 2009 09:02:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MjBpx-0001Zu-3e for qemu-devel@nongnu.org; Thu, 03 Sep 2009 08:54:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MjBps-0001Xp-8y for qemu-devel@nongnu.org; Thu, 03 Sep 2009 08:54:48 -0400 Received: from [199.232.76.173] (port=45919 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjBps-0001Xk-4Q for qemu-devel@nongnu.org; Thu, 03 Sep 2009 08:54:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13294) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MjBpr-0007Uw-E6 for qemu-devel@nongnu.org; Thu, 03 Sep 2009 08:54:43 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n83Cs3JU020673; Thu, 3 Sep 2009 08:54:03 -0400 Received: from localhost (vpn-12-91.rdu.redhat.com [10.11.12.91]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n83Cs0cl007072; Thu, 3 Sep 2009 08:54:02 -0400 From: Amit Shah To: qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Date: Thu, 3 Sep 2009 18:23:31 +0530 Message-Id: <1251982412-11870-3-git-send-email-amit.shah@redhat.com> In-Reply-To: <1251982412-11870-2-git-send-email-amit.shah@redhat.com> References: <1251982412-11870-1-git-send-email-amit.shah@redhat.com> <1251982412-11870-2-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Amit Shah Subject: [Qemu-devel] [PATCH 1/2] char: Emit 'OPENED' events on char device open X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Notify users of the char interface whenever the file / connection is opened. The existing RESET event is triggered when the qemu char state is reset as well; which may not be as interesting as char device open events. Signed-off-by: Amit Shah --- qemu-char.c | 14 +++++++++++++- qemu-char.h | 1 + 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index c25ed1c..5fe882a 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -474,6 +474,8 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) chr->chr_write = mux_chr_write; chr->chr_update_read_handler = mux_chr_update_read_handler; chr->chr_accept_input = mux_chr_accept_input; + + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -622,6 +624,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) chr->chr_close = fd_chr_close; qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -913,8 +916,10 @@ static void pty_chr_state(CharDriverState *chr, int connected) * the virtual device linked to our pty. */ qemu_mod_timer(s->timer, qemu_get_clock(rt_clock) + 1000); } else { - if (!s->connected) + if (!s->connected) { qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); + } s->connected = 1; } } @@ -1152,6 +1157,7 @@ static CharDriverState *qemu_chr_open_tty(const char *filename) } chr->chr_ioctl = tty_serial_ioctl; qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } #else /* ! __linux__ && ! __sun__ */ @@ -1297,6 +1303,7 @@ static CharDriverState *qemu_chr_open_pp(const char *filename) chr->opaque = drv; qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -1576,6 +1583,7 @@ static CharDriverState *qemu_chr_open_win(const char *filename) return NULL; } qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -1675,6 +1683,7 @@ static CharDriverState *qemu_chr_open_win_pipe(const char *filename) return NULL; } qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -1689,6 +1698,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out) chr->opaque = s; chr->chr_write = win_chr_write; qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; } @@ -1823,6 +1833,7 @@ static CharDriverState *qemu_chr_open_udp(const char *def) chr->chr_write = udp_chr_write; chr->chr_update_read_handler = udp_chr_update_read_handler; chr->chr_close = udp_chr_close; + qemu_chr_event(chr, CHR_EVENT_OPENED); return chr; return_err: @@ -2029,6 +2040,7 @@ static void tcp_chr_connect(void *opaque) qemu_set_fd_handler2(s->fd, tcp_chr_read_poll, tcp_chr_read, NULL, chr); qemu_chr_reset(chr); + qemu_chr_event(chr, CHR_EVENT_OPENED); } #define IACSET(x,a,b,c) x[0] = a; x[1] = b; x[2] = c; diff --git a/qemu-char.h b/qemu-char.h index df620bc..d725d48 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -12,6 +12,7 @@ #define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */ #define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */ #define CHR_EVENT_CLOSED 5 /* connection closed */ +#define CHR_EVENT_OPENED 6 /* connection opened */ #define CHR_IOCTL_SERIAL_SET_PARAMS 1