From patchwork Thu Jan 13 13:00:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 78750 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 721AAB6F14 for ; Fri, 14 Jan 2011 00:13:50 +1100 (EST) Received: from localhost ([127.0.0.1]:38619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdMzl-0005Jv-Az for incoming@patchwork.ozlabs.org; Thu, 13 Jan 2011 08:13:41 -0500 Received: from [140.186.70.92] (port=42192 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdMn1-0005oO-6a for qemu-devel@nongnu.org; Thu, 13 Jan 2011 08:00:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdMmz-0004Wt-PR for qemu-devel@nongnu.org; Thu, 13 Jan 2011 08:00:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdMmz-0004Wk-6n for qemu-devel@nongnu.org; Thu, 13 Jan 2011 08:00:29 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0DD0Liq032468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Jan 2011 08:00:21 -0500 Received: from localhost (dhcp193-64.pnq.redhat.com [10.65.193.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0DD0JJS025159; Thu, 13 Jan 2011 08:00:20 -0500 From: Amit Shah To: qemu list Date: Thu, 13 Jan 2011 18:30:07 +0530 Message-Id: <62faeb8db4ea4f9dc0dd7778e9643d13947714ff.1294923288.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah , Gerd Hoffmann , Paul Brook Subject: [Qemu-devel] [PATCH 2/5] iohandlers: Introduce assign_fd_handlers() and remove_fd_handlers 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 This function will be used to assign fd handlers. Future commits will be enable each handler to be enabled/disabled individually. Make qemu_set_fd_handler2() a wrapper to assign_fd_handlers(). remove_fd_handlers() removes all the assigned handlers and marks the iohandler for deletion. It's a wrapper to assign_fd_handlers() with NULL handlers. Signed-off-by: Amit Shah --- qemu-char.h | 6 ++++++ vl.c | 24 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/qemu-char.h b/qemu-char.h index e6ee6c4..0ef83f4 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -109,6 +109,12 @@ size_t qemu_chr_mem_osize(const CharDriverState *chr); /* async I/O support */ +int assign_fd_handlers(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); +void remove_fd_handlers(int fd); int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, IOHandler *fd_read, diff --git a/vl.c b/vl.c index 9e365f6..38e0a3c 100644 --- a/vl.c +++ b/vl.c @@ -1036,11 +1036,11 @@ static IOHandlerRecord *get_iohandler(int fd) /* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ -int qemu_set_fd_handler2(int fd, - IOCanReadHandler *fd_read_poll, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque) +int assign_fd_handlers(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque) { IOHandlerRecord *ioh; @@ -1066,6 +1066,20 @@ int qemu_set_fd_handler2(int fd, return 0; } +void remove_fd_handlers(int fd) +{ + assign_fd_handlers(fd, NULL, NULL, NULL, NULL); +} + +int qemu_set_fd_handler2(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque) +{ + return assign_fd_handlers(fd, fd_read_poll, fd_read, fd_write, opaque); +} + int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write,