aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-10-17 15:31:34 +0200
committerMax Reitz <mreitz@redhat.com>2019-10-28 11:22:30 +0100
commit32558ce7a43dc7e8e3d065ac26eb2cdbfa34b36b (patch)
tree0870de2d8eb1c97dc7459b369d4996374df8bbcd /python
parentc7df3f19d22dc3c13f7ca64d7dc15a4389ee63b8 (diff)
iotests.py: Store socket files in $SOCK_DIR
iotests.py itself does not store socket files, but machine.py and qtest.py do. iotests.py needs to pass the respective path to them, and they need to adhere to it. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 20191017133155.5327-3-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'python')
-rw-r--r--python/qemu/machine.py15
-rw-r--r--python/qemu/qtest.py9
2 files changed, 18 insertions, 6 deletions
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 128a3d1dc2..2024e8b1b1 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -71,7 +71,7 @@ class QEMUMachine(object):
def __init__(self, binary, args=None, wrapper=None, name=None,
test_dir="/var/tmp", monitor_address=None,
- socket_scm_helper=None):
+ socket_scm_helper=None, sock_dir=None):
'''
Initialize a QEMUMachine
@@ -90,6 +90,8 @@ class QEMUMachine(object):
wrapper = []
if name is None:
name = "qemu-%d" % os.getpid()
+ if sock_dir is None:
+ sock_dir = test_dir
self._name = name
self._monitor_address = monitor_address
self._vm_monitor = None
@@ -106,12 +108,14 @@ class QEMUMachine(object):
self._qemu_full_args = None
self._test_dir = test_dir
self._temp_dir = None
+ self._sock_dir = sock_dir
self._launched = False
self._machine = None
self._console_set = False
self._console_device_type = None
self._console_address = None
self._console_socket = None
+ self._remove_files = []
# just in case logging wasn't configured by the main script:
logging.basicConfig()
@@ -236,8 +240,9 @@ class QEMUMachine(object):
if self._machine is not None:
args.extend(['-machine', self._machine])
if self._console_set:
- self._console_address = os.path.join(self._temp_dir,
+ self._console_address = os.path.join(self._sock_dir,
self._name + "-console.sock")
+ self._remove_files.append(self._console_address)
chardev = ('socket,id=console,path=%s,server,nowait' %
self._console_address)
args.extend(['-chardev', chardev])
@@ -253,8 +258,9 @@ class QEMUMachine(object):
if self._monitor_address is not None:
self._vm_monitor = self._monitor_address
else:
- self._vm_monitor = os.path.join(self._temp_dir,
+ self._vm_monitor = os.path.join(self._sock_dir,
self._name + "-monitor.sock")
+ self._remove_files.append(self._vm_monitor)
self._qemu_log_path = os.path.join(self._temp_dir, self._name + ".log")
self._qemu_log_file = open(self._qemu_log_path, 'wb')
@@ -279,6 +285,9 @@ class QEMUMachine(object):
shutil.rmtree(self._temp_dir)
self._temp_dir = None
+ while len(self._remove_files) > 0:
+ self._remove_if_exists(self._remove_files.pop())
+
def launch(self):
"""
Launch the VM and make sure we cleanup and expose the
diff --git a/python/qemu/qtest.py b/python/qemu/qtest.py
index 3f1d2cb325..d24ad04256 100644
--- a/python/qemu/qtest.py
+++ b/python/qemu/qtest.py
@@ -84,14 +84,17 @@ class QEMUQtestMachine(QEMUMachine):
'''A QEMU VM'''
def __init__(self, binary, args=None, name=None, test_dir="/var/tmp",
- socket_scm_helper=None):
+ socket_scm_helper=None, sock_dir=None):
if name is None:
name = "qemu-%d" % os.getpid()
+ if sock_dir is None:
+ sock_dir = test_dir
super(QEMUQtestMachine,
self).__init__(binary, args, name=name, test_dir=test_dir,
- socket_scm_helper=socket_scm_helper)
+ socket_scm_helper=socket_scm_helper,
+ sock_dir=sock_dir)
self._qtest = None
- self._qtest_path = os.path.join(test_dir, name + "-qtest.sock")
+ self._qtest_path = os.path.join(sock_dir, name + "-qtest.sock")
def _base_args(self):
args = super(QEMUQtestMachine, self)._base_args()