Received: from [140.186.70.92] (port=56101 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGAoF-00054q-Kk for qemu-devel@nongnu.org; Wed, 10 Nov 2010 08:33:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGAoA-00007W-Df for qemu-devel@nongnu.org; Wed, 10 Nov 2010 08:33:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGAoA-00006y-2P for qemu-devel@nongnu.org; Wed, 10 Nov 2010 08:33:50 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-char: Introduce Buffered driver References: <1288037204-27768-1-git-send-email-lcapitulino@redhat.com> <1288037204-27768-2-git-send-email-lcapitulino@redhat.com> <20101110103235.1639f23a@doriath> <20101110111228.3140caa8@doriath> Date: Wed, 10 Nov 2010 14:33:47 +0100 In-Reply-To: <20101110111228.3140caa8@doriath> (Luiz Capitulino's message of "Wed, 10 Nov 2010 11:12:28 -0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Luiz Capitulino writes: > On Wed, 10 Nov 2010 13:56:39 +0100 > Markus Armbruster wrote: > >> Luiz Capitulino writes: >> >> > On Wed, 10 Nov 2010 10:26:15 +0100 >> > Markus Armbruster wrote: [...] >> >> Unlike normal character drivers, this one can't be closed with >> >> qemu_chr_close(), can it? What happens if someone calls >> >> qemu_chr_close() on it? >> > >> > I guess it will explode, because this driver is not in the chardevs list >> > and our CharDriverState instance is allocated on the stack. >> > >> > Does a function comment solves the problem or do you have something else >> > in mind? >> >> A general OO rule: Having different constructors for different sub-types >> is okay, but once constructed, you should be able to use the objects >> without knowing of what sub-type they are. That includes destruction. > > We will have to add our MemoryDriver to the chardevs list, this has some > implications like being visible in qemu_chr_info() and qemu_chr_find(), > likely to also imply that we should choose a chr->filename. Not if we formalize the notion of an "internal use only" character device. Say, !chr->filename means it's internal, and internal ones aren't in chardevs. Make qemu_chr_close()'s QTAILQ_REMOVE() conditional !chr->filename. > Another detail is that we'll have to dynamically alocate our CharDriverState > instance. Not a problem, but adds a few more lines of code and a > qemu_free(). None of this is needed today. I doubt the alloc/free matters. > Really worth it? Your call. But if you decide not to, please add a suitable assertion to qemu_chr_close(), to make it obvious what went wrong when an internal character device explodes there. >> Exceptions prove the rule. Maybe this is one, maybe not. [...]