From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCpiQ-0008AL-Er for qemu-devel@nongnu.org; Mon, 10 Feb 2014 07:12:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCpiL-0003lh-2i for qemu-devel@nongnu.org; Mon, 10 Feb 2014 07:11:58 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCpiK-0003lb-Gz for qemu-devel@nongnu.org; Mon, 10 Feb 2014 07:11:53 -0500 Date: Mon, 10 Feb 2014 13:11:51 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140210121151.GC3088@irqsave.net> References: <1391769813-15437-1-git-send-email-famz@redhat.com> <1391769813-15437-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: <1391769813-15437-4-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 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 Le Friday 07 Feb 2014 =E0 18:43:31 (+0800), Fam Zheng a =E9crit : > 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 | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) >=20 > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests= .py > index e4fa9af..e2a3e73 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 > @@ -153,15 +159,20 @@ class VM(object): > stderr=3Dsys.stderr) > return p.wait() > =20 > + def qtest(self, cmd): > + return self._qtest.cmd(cmd) > + I am under the impression that you define this qtest method twice in the = same VM(object) class. > def launch(self): > '''Launch the VM and establish a QMP connection''' > devnull =3D open('/dev/null', 'rb') > 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 +183,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 +196,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