From patchwork Wed Dec 1 09:54:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 73827 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 ozlabs.org (Postfix) with ESMTPS id 5B59FB708B for ; Thu, 2 Dec 2010 02:09:11 +1100 (EST) Received: from localhost ([127.0.0.1]:58808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNoIs-00028h-UV for incoming@patchwork.ozlabs.org; Wed, 01 Dec 2010 10:09:06 -0500 Received: from [140.186.70.92] (port=36212 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNjPO-00077i-2x for qemu-devel@nongnu.org; Wed, 01 Dec 2010 04:55:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNjPM-0007Jt-Ql for qemu-devel@nongnu.org; Wed, 01 Dec 2010 04:55:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNjPM-0007Jk-F4 for qemu-devel@nongnu.org; Wed, 01 Dec 2010 04:55:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB19tO4i023996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 1 Dec 2010 04:55:24 -0500 Received: from localhost (ovpn-113-84.phx2.redhat.com [10.3.113.84]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB19tKTw027863; Wed, 1 Dec 2010 04:55:22 -0500 From: Amit Shah To: qemu list Date: Wed, 1 Dec 2010 15:24:26 +0530 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , Gerd Hoffmann , Juan Quintela Subject: [Qemu-devel] [PATCH v8 4/7] char: Add framework for a 'write unblocked' callback 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 The char layer can let users know that the driver will block on further input. For users interested in not blocking, they can assign a function pointer that will be called back when the driver becomes writable. This patch just adds the function pointers to the CharDriverState structure, future patches will enable the nonblocking and callback functionality. Signed-off-by: Amit Shah --- qemu-char.c | 3 +++ qemu-char.h | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 483a5fd..c16c2d7 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -202,11 +202,14 @@ void qemu_chr_add_handlers(CharDriverState *s, } s->chr_can_read = handlers->fd_can_read; s->chr_read = handlers->fd_read; + s->chr_write_unblocked = handlers->fd_write_unblocked; s->chr_event = handlers->fd_event; s->handler_opaque = opaque; if (s->chr_update_read_handler) s->chr_update_read_handler(s); + s->write_blocked = false; + /* We're connecting to an already opened device, so let's make sure we also get the open event */ if (s->opened) { diff --git a/qemu-char.h b/qemu-char.h index 62d395e..f9cbcc6 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -59,6 +59,9 @@ struct CharDriverState { IOEventHandler *chr_event; IOCanReadHandler *chr_can_read; IOReadHandler *chr_read; + IOHandler *chr_write_unblocked; + void (*update_fd_handlers)(struct CharDriverState *chr, + bool poll_out); void *handler_opaque; void (*chr_send_event)(struct CharDriverState *chr, int event); void (*chr_close)(struct CharDriverState *chr); @@ -68,6 +71,8 @@ struct CharDriverState { char *label; char *filename; int opened; + /* Are we in a blocked state? */ + bool write_blocked; QTAILQ_ENTRY(CharDriverState) next; };