Received: from eggs.gnu.org ([208.118.235.92]:53627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TA35m-0006r4-Kp for qemu-devel@nongnu.org; Fri, 07 Sep 2012 14:15:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TA35k-0006Lt-ER for qemu-devel@nongnu.org; Fri, 07 Sep 2012 14:15:46 -0400 Received: from indium.canonical.com ([91.189.90.7]:36759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TA35k-0006Lh-6c for qemu-devel@nongnu.org; Fri, 07 Sep 2012 14:15:44 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TA35j-0001j0-5m for ; Fri, 07 Sep 2012 18:15:43 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 298952E8079 for ; Fri, 7 Sep 2012 18:15:43 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Fri, 07 Sep 2012 18:07:28 -0000 From: Buck <1047470@bugs.launchpad.net> Sender: bounces@canonical.com References: <20120907154742.10241.91584.malonedeb@gac.canonical.com> Message-Id: <20120907180728.8257.75066.launchpad@chaenomeles.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 1047470] Re: qemu/kvm hangs reading from serial console Reply-To: Bug 1047470 <1047470@bugs.launchpad.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ** Description changed: This is for a qemu-kvm running on RHEL 5, so it's pretty old, but i think the problem still exists in 1.2 = We have conman running on our hosts, connecting to the kvm/qemu's using - virsh console + =C2=A0=C2=A0=C2=A0=C2=A0virsh console which just opens up the console /dev/pts/slave that qemu opens up when run with options - -nographic - -serial mon:pty + =C2=A0=C2=A0=C2=A0=C2=A0-nographic + =C2=A0=C2=A0=C2=A0=C2=A0-serial mon:pty = - Sometimes virsh console exits and then qemu locks up. + Sometimes virsh console exits and then qemu locks up[*]. My guess is that something like this happens: = virsh console exits qemu does a select() on /dev/ptmx (and other FDs) select() returns the FD of /dev/ptmx in the read-fdset qemu does a read() read() returns -1 (EIO) qemu does other stuff for a while select() ... /dev/ptmx read() .. EIO other stuff select() ... read() ... select() ... read() ... select() conman starts a new virsh console that connects qemu does a read() read() blocks b/c there is now a writer on the tty slave = So i don't see any way around this, given the sorta rudi- mentary semantics of TTY IO on Linux (not that i know of any platform that does it better ... ?), except ... = maybe qemu should - fcntl(master_fd, F_SETFL, flags | O_NONBLOCK) = + =C2=A0=C2=A0=C2=A0=C2=A0fcntl(master_fd, F_SETFL, flags | O_NONBLOCK) in qemu-char.c:qemu_char_open_pty() - and be prepared to handle E_WOULDBLOCK|E_AGAIN in = + and be prepared to handle E_WOULDBLOCK|E_AGAIN in qemu-char.c:fd_chr_read() ... ? = --buck = [*] i think, b/c in the old version we are running, sometimes - the guest spits out the - ^] - character to its console, and virsh console reads it and - doesn't check to see if its from stdin or the pty and exits, = - which, i think, can be fixed like this: + =C2=A0=C2=A0=C2=A0=C2=A0the guest spits out the + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0^] + =C2=A0=C2=A0=C2=A0=C2=A0character to its console, and virsh console reads= it and + =C2=A0=C2=A0=C2=A0=C2=A0doesn't check to see if its from stdin or the pty= and exits, + =C2=A0=C2=A0=C2=A0=C2=A0which, i think, can be fixed like this: = --- libvirt-0.8.2/tools/console.c.ctrl_close_bracket_handling_fix 2= 012-09-06 10:30:43.606997191 -0400 +++ libvirt-0.8.2/tools/console.c 2012-09-06 10:34:52.154000464 -04= 00 @@ -155,6 +155,7 @@ int vshRunConsole(const char *tty) { = - /* Quit if end of file, or we got the Ctrl-] key */ - if (!got || + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Quit if end of file, or we got the Ctrl-] = key */ + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!got || + fds[i].fd =3D=3D STDIN_FILENO && - (got =3D=3D 1 && - buf[0] =3D=3D CTRL_CLOSE_BRACKET)) - goto done; + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(got =3D=3D 1 && + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0buf[0] =3D=3D C= TRL_CLOSE_BRACKET)) + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto done; -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1047470 Title: qemu/kvm hangs reading from serial console Status in QEMU: New Bug description: This is for a qemu-kvm running on RHEL 5, so it's pretty old, but i think the problem still exists in 1.2 We have conman running on our hosts, connecting to the kvm/qemu's using =C2=A0=C2=A0=C2=A0=C2=A0virsh console which just opens up the console /dev/pts/slave that qemu opens up when run with options =C2=A0=C2=A0=C2=A0=C2=A0-nographic =C2=A0=C2=A0=C2=A0=C2=A0-serial mon:pty Sometimes virsh console exits and then qemu locks up[*]. My guess is that something like this happens: virsh console exits qemu does a select() on /dev/ptmx (and other FDs) select() returns the FD of /dev/ptmx in the read-fdset qemu does a read() read() returns -1 (EIO) qemu does other stuff for a while select() ... /dev/ptmx read() .. EIO other stuff select() ... read() ... select() ... read() ... select() conman starts a new virsh console that connects qemu does a read() read() blocks b/c there is now a writer on the tty slave So i don't see any way around this, given the sorta rudi- mentary semantics of TTY IO on Linux (not that i know of any platform that does it better ... ?), except ... maybe qemu should =C2=A0=C2=A0=C2=A0=C2=A0fcntl(master_fd, F_SETFL, flags | O_NONBLOCK) in qemu-char.c:qemu_char_open_pty() and be prepared to handle E_WOULDBLOCK|E_AGAIN in qemu-char.c:fd_chr_read() ... ? --buck [*] i think, b/c in the old version we are running, sometimes =C2=A0=C2=A0=C2=A0=C2=A0the guest spits out the =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0^] =C2=A0=C2=A0=C2=A0=C2=A0character to its console, and virsh console reads= it and =C2=A0=C2=A0=C2=A0=C2=A0doesn't check to see if its from stdin or the pty= and exits, =C2=A0=C2=A0=C2=A0=C2=A0which, i think, can be fixed like this: --- libvirt-0.8.2/tools/console.c.ctrl_close_bracket_handling_fix 2= 012-09-06 10:30:43.606997191 -0400 +++ libvirt-0.8.2/tools/console.c 2012-09-06 10:34:52.154000464 -04= 00 @@ -155,6 +155,7 @@ int vshRunConsole(const char *tty) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* Quit if end of file, or we got the Ctrl-] = key */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!got || + fds[i].fd =3D=3D STDIN_FILENO && =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(got =3D=3D 1 && =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0buf[0] =3D=3D C= TRL_CLOSE_BRACKET)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0goto done; To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1047470/+subscriptions