From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56102 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2OE4-0002xF-DF for qemu-devel@nongnu.org; Wed, 23 Mar 2011 09:35:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2OCg-0004Vz-Sg for qemu-devel@nongnu.org; Wed, 23 Mar 2011 09:34:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2OCg-0004Vu-JA for qemu-devel@nongnu.org; Wed, 23 Mar 2011 09:34:26 -0400 From: Juan Quintela In-Reply-To: <2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6.1300712809.git.amit.shah@redhat.com> (Amit Shah's message of "Mon, 21 Mar 2011 18:39:22 +0530") References: <2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6.1300712809.git.amit.shah@redhat.com> Date: Wed, 23 Mar 2011 14:32:44 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 7/7] char: Prevent multiple devices opening same chardev Reply-To: quintela@redhat.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu list Amit Shah wrote: > Prevent: > > -chardev socket,path=/tmp/foo,server,nowait,id=c0 \ > -device virtserialport,chardev=c0,id=vs0 \ > -device virtserialport,chardev=c0,id=vs1 > > Reported-by: Mike Cao > Signed-off-by: Amit Shah > @@ -197,6 +197,10 @@ void qemu_chr_add_handlers(CharDriverState *s, > IOEventHandler *fd_event, > void *opaque) > { > + if (!opaque) { > + /* chr driver being released. */ > + s->assigned = 0; > + } > s->chr_can_read = fd_can_read; > s->chr_read = fd_read; > s->chr_event = fd_event; I preffer to decide that a handler is empty when fd_can_read/fd_read and fd_event are all NULL, and don't take into account the opaque handler. This covers the case where opaque is NULL because state is implicit on the other functions. Later, Juan.