All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: [Qemu-devel] [PULL 10/13] qemu-iotests: iotests.VM: remove qtest socket on error
Date: Tue, 12 Apr 2016 18:19:05 +0200	[thread overview]
Message-ID: <1460477948-24686-11-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1460477948-24686-1-git-send-email-kwolf@redhat.com>

From: Sascha Silbe <silbe@linux.vnet.ibm.com>

On error, VM.launch() cleaned up the monitor unix socket, but left the
qtest unix socket behind. This caused the remaining sub-tests to fail
with EADDRINUSE:

+======================================================================
+ERROR: testQuorum (__main__.TestFifoQuorumEvents)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "148", line 63, in setUp
+    self.vm.launch()
+  File "/home6/silbe/qemu/tests/qemu-iotests/iotests.py", line 247, in launch
+    self._qmp.accept()
+  File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 141, in accept
+    return self.__negotiate_capabilities()
+  File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 57, in __negotiate_capabilities
+    raise QMPConnectError
+QMPConnectError
+
+======================================================================
+ERROR: testQuorum (__main__.TestQuorumEvents)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+  File "148", line 63, in setUp
+    self.vm.launch()
+  File "/home6/silbe/qemu/tests/qemu-iotests/iotests.py", line 244, in launch
+    self._qtest = qtest.QEMUQtestProtocol(self._qtest_path, server=True)
+  File "/home6/silbe/qemu/tests/qemu-iotests/../../scripts/qtest.py", line 33, in __init__
+    self._sock.bind(self._address)
+  File "/usr/lib64/python2.7/socket.py", line 224, in meth
+    return getattr(self._sock,name)(*args)
+error: [Errno 98] Address already in use

Fix this by cleaning up both the monitor socket and the qtest socket iff
they exist.

Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Bo Tu <tubo@linux.vnet.ibm.com>
Message-id: 1459848109-29756-4-git-send-email-silbe@linux.vnet.ibm.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 8499e1b..fb5c482 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -16,6 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+import errno
 import os
 import re
 import subprocess
@@ -247,7 +248,8 @@ class VM(object):
             self._qmp.accept()
             self._qtest.accept()
         except:
-            os.remove(self._monitor_path)
+            _remove_if_exists(self._monitor_path)
+            _remove_if_exists(self._qtest_path)
             raise
 
     def shutdown(self):
@@ -409,6 +411,15 @@ class QMPTestCase(unittest.TestCase):
         event = self.wait_until_completed(drive=drive)
         self.assert_qmp(event, 'data/type', 'mirror')
 
+def _remove_if_exists(path):
+    '''Remove file object at path if it exists'''
+    try:
+        os.remove(path)
+    except OSError as exception:
+        if exception.errno == errno.ENOENT:
+           return
+        raise
+
 def notrun(reason):
     '''Skip this test suite'''
     # Each test in qemu-iotests has a number ("seq")
-- 
1.8.3.1

  parent reply	other threads:[~2016-04-12 16:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 16:18 [Qemu-devel] [PULL 00/13] Block patches for 2.6 Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 01/13] iotests: fix the broken 026.nocache output Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 02/13] qemu-img: fix formatting of error message Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 03/13] block: initialize qcrypto API at startup Kevin Wolf
2016-04-12 16:18 ` [Qemu-devel] [PULL 04/13] iotests: Make 150 use qemu-img map instead of du Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 05/13] vpc: fix return value check for blk_pwrite Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 06/13] qcow2: Prevent backing file names longer than 1023 Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 07/13] MAINTAINERS: Block layer core, qcow2 and blkdebug Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 08/13] qemu-iotests: check: don't place files with predictable names in /tmp Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 09/13] qemu-iotests: fix 051 on non-PC architectures Kevin Wolf
2016-04-12 16:19 ` Kevin Wolf [this message]
2016-04-12 16:19 ` [Qemu-devel] [PULL 11/13] qemu-iotests: 148: properly skip test if quorum support is missing Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 12/13] qemu-iotests: 068: don't require KVM Kevin Wolf
2016-04-12 16:19 ` [Qemu-devel] [PULL 13/13] qemu-iotests: iotests.py: get rid of __all__ Kevin Wolf
2016-04-13 15:32 ` [Qemu-devel] [PULL 00/13] Block patches for 2.6 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460477948-24686-11-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.