From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF3cb-0007KP-6O for qemu-devel@nongnu.org; Thu, 29 Aug 2013 10:54:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF3cV-0000vo-A1 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 10:54:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF3cU-0000vg-S9 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 10:54:47 -0400 Date: Thu, 29 Aug 2013 10:54:41 -0400 From: Luiz Capitulino Message-ID: <20130829105441.5bd0d202@redhat.com> In-Reply-To: <1377571931-9144-3-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1377571931-9144-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1377571931-9144-3-git-send-email-xiawenc@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V2 2/3] qemu-iotests: add infrastructure of fd passing via SCM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, anthony@codemonkey.ws, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com On Tue, 27 Aug 2013 10:52:10 +0800 Wenchao Xia wrote: > This patch make use of the compiled scm helper program to transfer > fd via unix socket at runtime. I'm not familiar with the qemu-iotests and I can't tell if this makes sense. Kevin, Stefan, Markus, can you help reviewing this? > > Signed-off-by: Wenchao Xia > --- > QMP/qmp.py | 6 ++++++ > tests/qemu-iotests/check | 1 + > tests/qemu-iotests/iotests.py | 26 ++++++++++++++++++++++++++ > 3 files changed, 33 insertions(+), 0 deletions(-) > > diff --git a/QMP/qmp.py b/QMP/qmp.py > index c551df1..074f09a 100644 > --- a/QMP/qmp.py > +++ b/QMP/qmp.py > @@ -188,3 +188,9 @@ class QEMUMonitorProtocol: > > def settimeout(self, timeout): > self.__sock.settimeout(timeout) > + > + def get_sock_fd(self): > + return self.__sock.fileno() > + > + def is_scm_available(self): > + return self.__sock.family == socket.AF_UNIX > diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check > index 74628ae..2f7f78e 100755 > --- a/tests/qemu-iotests/check > +++ b/tests/qemu-iotests/check > @@ -164,6 +164,7 @@ QEMU_IO -- $QEMU_IO > IMGFMT -- $FULL_IMGFMT_DETAILS > IMGPROTO -- $FULL_IMGPROTO_DETAILS > PLATFORM -- $FULL_HOST_DETAILS > +SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER > > EOF > #MKFS_OPTIONS -- $FULL_MKFS_OPTIONS > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index 33ad0ec..d40b2de 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -38,6 +38,8 @@ imgfmt = os.environ.get('IMGFMT', 'raw') > imgproto = os.environ.get('IMGPROTO', 'file') > test_dir = os.environ.get('TEST_DIR', '/var/tmp') > > +socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') > + > def qemu_img(*args): > '''Run qemu-img and return the exit code''' > devnull = open('/dev/null', 'r+') > @@ -80,6 +82,12 @@ class VM(object): > '-display', 'none', '-vga', 'none'] > self._num_drives = 0 > > + #This can be used to add unused monitor > + def add_monitor_telnet(self, ip, port): > + args = 'tcp:%s:%d,server,nowait,telnet' % (ip, port) > + self._args.append('-monitor') > + self._args.append(args) > + > def add_drive(self, path, opts=''): > '''Add a virtio-blk drive to the VM''' > options = ['if=virtio', > @@ -112,6 +120,24 @@ class VM(object): > self._args.append(','.join(options)) > return self > > + #Sendmsg must carry out some data to get qemu's notice, so send a blank > + #by default. > + def send_fd_scm(self, fd, msg=' '): > + #In iotest.py, the qmp should always use unix socket. > + assert self._qmp.is_scm_available() > + fd_bin = socket_scm_helper > + if os.path.exists(fd_bin) == False: > + print "Scm help program does not present, path %s." % fd_bin > + return -1 > + fd_param = ["%s" % fd_bin, > + "%d" % self._qmp.get_sock_fd(), > + "%d" % fd, > + "%s" % msg] > + devnull = open('/dev/null', 'rb') > + p = subprocess.Popen(fd_param, stdin=devnull, stdout=sys.stdout, > + stderr=sys.stderr) > + return p.wait() > + > def launch(self): > '''Launch the VM and establish a QMP connection''' > devnull = open('/dev/null', 'rb')