Received: from eggs.gnu.org ([2001:4830:134:3::10]:60279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8W1z-0004Ov-04 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:22:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8W1t-0006oN-Hj for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:22:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8W1t-0006oG-8J for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:22:13 -0500 Date: Wed, 29 Jan 2014 15:22:09 +0100 From: Stefan Hajnoczi Message-ID: <20140129142209.GE23531@stefanha-thinkpad.muc.redhat.com> References: <1390984843-2101-1-git-send-email-famz@redhat.com> <1390984843-2101-3-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1390984843-2101-3-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/4] qemu-iotests: Add VM method qtest_cmd() to iotests.py List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org On Wed, Jan 29, 2014 at 04:40:41PM +0800, Fam Zheng wrote: > This will allow test case to run command in qtest protocol. It's > write-only for now. > > Signed-off-by: Fam Zheng > --- > tests/qemu-iotests/iotests.py | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index e4fa9af..ca79d09 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -153,13 +153,16 @@ class VM(object): > stderr=sys.stderr) > return p.wait() > > + def qtest_cmd(self, cmd): > + self._popen.stdin.write(cmd + "\n") > + > def launch(self): > '''Launch the VM and establish a QMP connection''' > - devnull = open('/dev/null', 'rb') > qemulog = open(self._qemu_log_path, 'wb') > try: > self._qmp = qmp.QEMUMonitorProtocol(self._monitor_path, server=True) > - self._popen = subprocess.Popen(self._args, stdin=devnull, stdout=qemulog, > + self._popen = subprocess.Popen(self._args, stdin=subprocess.PIPE, > + stdout=qemulog, > stderr=subprocess.STDOUT) Commit 0fd05e8dd1ee7ae143fba3d6bcc6abe3fbeaeb34 ("qemu-iotests: start vms in qtest mode") put qtest on stdio. I think that was a mistake and it should be fixed if you want to drive qtest. Let's not mix qtest output with QEMU stderr. If you need to drive qtest, put it on a dedicated UNIX domain socket (just like QMP). Implement the qtest protocol as documented in qtest.c: * Line based protocol, request/response based. Server can send async messages * so clients should always handle many async messages before the response * comes in. Stefan