From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu0AD-0007eA-0A for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:44:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bu0A8-0003Sc-4f for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu0A7-0003SC-RD for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:44:20 -0400 Date: Tue, 11 Oct 2016 17:44:15 +0100 From: "Daniel P. Berrange" Message-ID: <20161011164415.GK14917@redhat.com> Reply-To: "Daniel P. Berrange" References: <20161003094704.18087-1-marcandre.lureau@redhat.com> <20161003094704.18087-3-marcandre.lureau@redhat.com> <864e85e8-6fe4-d89e-7223-9e9680da4910@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] char: use a fixed idx for child muxed chr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: Claudio Imbrenda , qemu-devel@nongnu.org, pbonzini@redhat.com, kraxel@redhat.com On Tue, Oct 11, 2016 at 04:18:46PM +0000, Marc-Andr=C3=A9 Lureau wrote: > Hi >=20 > On Tue, Oct 11, 2016 at 6:28 PM Marc-Andr=C3=A9 Lureau < > marcandre.lureau@gmail.com> wrote: >=20 > > Hi > > > > On Tue, Oct 11, 2016 at 4:21 PM Claudio Imbrenda < > > imbrenda@linux.vnet.ibm.com> wrote: > > > > Hi, > > > > I noticed that this patch kills the Qemu monitor for me. If I start a > > text-mode guest with -nographic, then I can't switch to the monitor a= ny > > longer with Ctrl+a c . The guest works otherwise, e.g. I can login fr= om > > the console. > > > > Tested on s390, but I think it's a more general issue, since the patc= h > > is not arch-dependent. > > > > > > On 03/10/16 11:47, Marc-Andr=C3=A9 Lureau wrote: > > > mux_chr_update_read_handler() is adding a new mux_cnt each time > > > mux_chr_update_read_handler() is called, it's not possible to actua= lly > > > update the "child" chr callbacks that were set previously. This may= lead > > > to crashes if the "child" chr is destroyed: > > > > > > > > > My understanding was quite wrong, it was assuming that each mux user/= fe > > was a seperate chardev, that's not how it works. > > > > The patch should probably be reverted until a better solution comes u= p. I > > am looking at it, but no solution yet. > > > > (obviously, it would be nice to have some minimal tests for mux, let = see > > if I get there) > > -- > > >=20 > I am quite undecided how to fix this. qemu_chr_add_handlers users have = no > associated tag: this works ok as long as there is a single user per > chardev. But it becomes problematic when there are multiple users, when= the > backing chardev is a mux: the mux will just grow more fe handlers, And = you > can't ever remove your fe callback which may lead to a crash. I am > surprised this problem didn't raise before. >=20 > I can imagine 2 solutions, either to associate each fe with it's opaque > pointer to lookup the corresponding mux registered callbacks (less > intrusive, yet not very clean), or to create a tag when calling > qemu_chr_add_handlers() which can be used later with a new function lik= e > qemu_chr_remove_handlers(). This would be very intrusive, since all chr= fe > will have to hold a tag in their struct and pass it accordingly. >=20 > Other thoughts? Not sure if this is immediately helpful to your scneario or not, but I'd like to see the qemu_chr_add_handlers method removed long term, and everything converted to use the qemu_chr_fe_add_watch function instead. This reverses the data flow pattern - with chr_add_handlers the chardev code pushes data from the backend into the frontends, but with fe_add_watch the frontend pulls data from the backend. To properly fix the non-blocking writes from the frontend to the backend[1] will likely require use of qemu_chr_fe_add_watch, and so having that function used for everything will make the code clearer overall IMHO. Regards, Daniel [1] eg the long term solution to replace this hack: commit 90f998f5f4267a0c22e983f533d19b9de1849283 Author: Daniel P. Berrange Date: Tue Sep 6 14:56:05 2016 +0100 char: convert qemu_chr_fe_write to qemu_chr_fe_write_all =20 --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr= / :|