From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDB3H-00028B-9a for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:58:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDB38-0000Xu-Kc for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:58:55 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDB38-0000Xf-2Q for qemu-devel@nongnu.org; Tue, 11 Feb 2014 05:58:46 -0500 Date: Tue, 11 Feb 2014 11:58:42 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140211105842.GC2978@irqsave.net> References: <1392100862-25943-1-git-send-email-famz@redhat.com> <1392100862-25943-4-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1392100862-25943-4-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 3/5] qemu-iotests: Add VM method qtest() 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, Stefan Hajnoczi , pbonzini@redhat.com The Tuesday 11 Feb 2014 =E0 14:41:00 (+0800), Fam Zheng wrote : > This will allow test case to run command in qtest protocol. It's > write-only for now. >=20 > Signed-off-by: Fam Zheng > --- > tests/qemu-iotests/iotests.py | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests= .py > index e4fa9af..27547ac 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -21,9 +21,13 @@ import re > import subprocess > import string > import unittest > -import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '.= .', '..', 'scripts', 'qmp')) > +import sys > +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 's= cripts', 'qmp')) > +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 's= cripts', 'qtest')) > import qmp > +import qtest > import struct > +import socket > =20 > __all__ =3D ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io', > 'VM', 'QMPTestCase', 'notrun', 'main'] > @@ -80,10 +84,12 @@ class VM(object): > def __init__(self): > self._monitor_path =3D os.path.join(test_dir, 'qemu-mon.%d' % = os.getpid()) > self._qemu_log_path =3D os.path.join(test_dir, 'qemu-log.%d' %= os.getpid()) > + self._qtest_path =3D os.path.join(test_dir, 'qemu-qtest.%d' % = os.getpid()) > self._args =3D qemu_args + ['-chardev', > 'socket,id=3Dmon,path=3D' + self._monitor_path, > '-mon', 'chardev=3Dmon,mode=3Dcontrol', > - '-qtest', 'stdio', '-machine', 'accel=3Dqtest', > + '-qtest', 'unix:path=3D' + self._qtest_path, > + '-machine', 'accel=3Dqtest', > '-display', 'none', '-vga', 'none'] > self._num_drives =3D 0 > =20 > @@ -159,9 +165,11 @@ class VM(object): > qemulog =3D open(self._qemu_log_path, 'wb') > try: > self._qmp =3D qmp.QEMUMonitorProtocol(self._monitor_path, = server=3DTrue) > + self._qtest =3D qtest.QEMUQtestProtocol(self._qtest_path, = server=3DTrue) > self._popen =3D subprocess.Popen(self._args, stdin=3Ddevnu= ll, stdout=3Dqemulog, > stderr=3Dsubprocess.STDOUT) > self._qmp.accept() > + self._qtest.accept() > except: > os.remove(self._monitor_path) > raise > @@ -172,6 +180,7 @@ class VM(object): > self._qmp.cmd('quit') > self._popen.wait() > os.remove(self._monitor_path) > + os.remove(self._qtest_path) > os.remove(self._qemu_log_path) > self._popen =3D None > =20 > @@ -184,6 +193,10 @@ class VM(object): > =20 > return self._qmp.cmd(cmd, args=3Dqmp_args) > =20 > + def qtest(self, cmd): > + '''Send a qtest command to guest''' > + return self._qtest.cmd(cmd) > + > def get_qmp_event(self, wait=3DFalse): > '''Poll for one queued QMP events and return it''' > return self._qmp.pull_event(wait=3Dwait) > --=20 > 1.8.5.4 >=20 >=20 Reviewed-by: Benoit Canet