Received: from eggs.gnu.org ([2001:4830:134:3::10]:32860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c56xW-0005ik-PF for qemu-devel@nongnu.org; Fri, 11 Nov 2016 03:13:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c56xS-00046p-Af for qemu-devel@nongnu.org; Fri, 11 Nov 2016 03:13:14 -0500 References: <1478768797-26401-1-git-send-email-thuth@redhat.com> <20161110230106.GB18868@umbus.fritz.box> From: Thomas Huth Message-ID: <306cb3c2-b6e7-8de5-d327-6481709f1835@redhat.com> Date: Fri, 11 Nov 2016 09:13:00 +0100 MIME-Version: 1.0 In-Reply-To: <20161110230106.GB18868@umbus.fritz.box> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pf9m3OXnIvnkBgT1CvkPkXceVNmqiauKJ" Subject: Re: [Qemu-devel] [PATCH] spapr-vty: Fix bad assert() statement List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org, pbonzini@redhat.com, Gerd Hoffmann This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Pf9m3OXnIvnkBgT1CvkPkXceVNmqiauKJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11.11.2016 00:01, David Gibson wrote: > On Thu, Nov 10, 2016 at 10:06:37AM +0100, Thomas Huth wrote: >> When using the serial console in the GTK interface of QEMU (and >> QEMU has been compiled with CONFIG_VTE), it is possible to trigger >> the assert() statement in vty_receive() in spapr_vty.c by pasting >> a chunk of text with length > 16 into the QEMU window. >> Most of the other serial backends seem to simply drop characters >> that they can not handle, so I think we should also do the same in >> spapr-vty to fix this issue. And since it is quite ugly when pasted >> text is chopped after 16 bytes, we also increase the size of the >> input buffer here so that we can at least handle a couple of text >> lines. >=20 > Adding Paolo to CC, as qemu-char maintainer. >=20 > So, vastly increasing the buffer like this doesn't seem right - the > plain 16550 serial driver doesn't maintain a buffer bigger than its > small internal FIFO (32 characters IIRC) - or a single byte if the > FIFO is disabled. >=20 > I thought the other side of the char driver was supposed to call > can_receive() first and not deliver more bytes than we can handle - > hence the assert. Right. The real bug seems to be on the front end side: gd_vc_in() in ui/gtk.c calls qemu_chr_be_write() without checking the qemu_chr_be_can_write() first (which internally calls the can_receive() function of the backend). So we likely need to fix gd_vc_in() to use qemu_chr_be_can_write() instead ... but I'm currently puzzled whether that can be done at all, since this seems to be a callback function - and we likely can not simply loop/yield here, can we? > That said, I think vty_can_receive() has a bug - looking at other > drivers, I think it's supposed to return the amount of buffer space > available, but we're just returning 0 or 1. Although AFAICT that > should still work, just inefficiently. Right, it should return the amount of free space instead. > If you use a serial port with the same GTK interface, do you get the > same problem with pastes of >16 characters being truncated? Yes, I tried the coldfire image from http://wiki.qemu.org/download/coldfire-test-0.1.tar.bz2 and that even only accepts 1 byte when doing the copy-n-paste and drops everything else. So copy-n-paste is currently completely broken there, too. Thomas >> Buglink: https://bugs.launchpad.net/qemu/+bug/1639322 --Pf9m3OXnIvnkBgT1CvkPkXceVNmqiauKJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJYJX2RAAoJEC7Z13T+cC21d3wP/RjDRuRJEPc7K4WjcMGQZcp+ xooOj+yxkmAjugr8oSjiAaAr/DBg0KU4tyfgqmSWtY67H6VWpjqsPQvgMkaRKzGo PGNkKsKSC3Inv7yEgToHIiDqWq0KiHCL+DYtjbRQtvnsYgAONRZBIOj9xJDQQOcS 3LFntx03pYDb7OxrnmVL4+3ciPPdVAympmDg8Tq//ID5njuR81VybZi4cX0MeFbx Os7DJ+Si7b8L6b7ahQBRnK/PHSnEBeA55fqagSgOsZl1SYwdVk60SRJCNn+ZKbFp wSvh43W5MiNbGbgtuavuGmrD9vcW9cpBmYin3xT/U7pUAP09kLJN+XaEOUzWnjIC UCo07y4NJeamN67p8+llJcLnZSSQn0E3WecvH3k9b4TTZQjzpgJUxAAxeZ5nL+pE Kk8WfUsth8KVmg5mfIb9kX+gF+MQgfjf3EjTFN9ygvbEhict4uvP0Inn9ybCAKoW d/tT/TlMYnGRgBlDg3L/tvY3FoQ2T7mK79ZrJuSbCdQOacS5nIWOrnM3GLFIgpCU WwcrxjMhJRSTdrJ0kjfDjOV3YIkn7vQI38lJr/k8L67Oseut+LnK2YybHilkeHJL wgahobZvdDcjA8yDJqHUtbr+aM+SRgLEbKZfLkWf/uenCkyHmOzuzjFeUdNWx17b 9Vgm3kKOkR0qwBqZGuPW =dGbG -----END PGP SIGNATURE----- --Pf9m3OXnIvnkBgT1CvkPkXceVNmqiauKJ--