Received: from eggs.gnu.org ([2001:4830:134:3::10]:40223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6eNo-0004Oh-8C for qemu-devel@nongnu.org; Fri, 24 Jan 2014 05:53:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6eNh-0005x0-LB for qemu-devel@nongnu.org; Fri, 24 Jan 2014 05:53:08 -0500 Received: from mailer.skroutz.gr ([185.6.78.18]:55243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6eNh-0005ww-6P for qemu-devel@nongnu.org; Fri, 24 Jan 2014 05:53:01 -0500 Date: Fri, 24 Jan 2014 12:52:52 +0200 From: Apollon Oikonomopoulos Message-ID: <20140124105252.GA12207@marvin.ws.skroutz.gr> References: <20140123112351.GA21477@T430.redhat.com> <20140123084402.3c82b2e9@redhat.com> <20140123085454.2c0fd29a@redhat.com> <52E1364D.2010807@grnet.gr> <20140123132858.75ce8507@redhat.com> <52E23CF4.7030302@grnet.gr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <52E23CF4.7030302@grnet.gr> Subject: Re: [Qemu-devel] Possible bug in monitor code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stratos Psomadakis Cc: Fam Zheng , qemu-devel@nongnu.org, Luiz Capitulino , Synnefo Development , Dimitris Aragiorgis , Ganeti Development --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi all, On 12:14 Fri 24 Jan , Stratos Psomadakis wrote: > On 01/23/2014 08:28 PM, Luiz Capitulino wrote: > > Not yet, I may have some time tomorrow. How reproducible is it for > > you? > > We can trigger it (by following the steps described in the first mail) > consistently. > > > Another question: have you tried to reproduce with an old qemu version > > (say v1.0) to see if this bug always existed? If the bug was introduced > > in some recent QEMU version you could try to bisect it. > > v1.1 is not affected. I checked the code and it seems the monitor code > has been refactored since v1.1. > > > Maybe you could try to reproduce with a different subsystem so that we > > can rule out or confirm monitor's involvement? Like -serial? > > It's actually a fault of the monitor_flush() function. As far as I can > understand, monitor_flush() calls qemu_chr_fe_write() and doesn't handle > all of the return codes / error cases properly (as I described in a > previous mail). If you check the function, you'll see that the final > case (where it set ups a watch / callback) always assumes an EAGAIN / > EWOULDBLOCK error. > > If you can verify / confirm that this is the case and that the patch > sent resolves the issue in a sane / correct way, I'll resubmit it > properly (with git-format-patch, a git log msg etc). Please see the attached testcase (python script) that programmatically reproduces this. Sample output with qemu 1.7.0: ------------------------------------------------------------------------ $ ./test-qmp.py Spawning qemu Connecting client 1 Monitor output: {"QMP": {"version": {"qemu": {"micro": 0, "minor": 7, "major": 1}, "package": " (Debian 1.7.0+dfsg-2)"}, "capabilities": []}} Connecting client 2 Monitor output: (timeout, disconnecting) Disconnecting client 1 Connecting client 3 Monitor output {"QMP": {"version": {"qemu": {"micro": 0, "minor": 7, "major": 1}, "package": " (Debian 1.7.0+dfsg-2)"}, "capabilities": []}} {"QMP": {"version": {"qemu": {"micro": 0, "minor": 7, "major": 1}, "package": " (Debian 1.7.0+dfsg-2)"}, "capabilities": []}} Terminating qemu qemu: terminating on signal 15 from pid 11269 ------------------------------------------------------------------------ Regards, Apollon --Q68bSM7Ycu6FN28Q Content-Type: text/x-python; charset=utf-8 Content-Disposition: attachment; filename="test-qmp.py" #!/usr/bin/python import os import socket import tempfile import subprocess from time import sleep sock_path = tempfile.mktemp() print "Spawning qemu" print qemu = subprocess.Popen(["/usr/bin/qemu", "-chardev", "socket,id=mon0,path=%s,server,nowait" % sock_path, "-mon", "chardev=mon0,mode=control", "-display", "none"]) # Wait for qemu to initialize while not os.path.exists(sock_path): sleep(0.1) print "Connecting client 1\n" cl1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) cl1.connect(sock_path) print "Monitor output:" print cl1.recv(1024) print print "Connecting client 2\n" cl2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) cl2.settimeout(1) try: cl2.connect(sock_path) print "Monitor output:" print cl2.recv(1024) except socket.timeout: print "(timeout, disconnecting)\n" cl2.close() print "Disconnecting client 1\n" cl1.close() print "Connecting client 3\n" cl3 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) cl3.connect(sock_path) print "Monitor output" print cl3.recv(1024) cl3.close() print "Terminating qemu" qemu.terminate() qemu.wait() --Q68bSM7Ycu6FN28Q--