iotests.py: qemu_nbd_popen: remove pid file after use
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 5 Feb 2021 16:37:17 +0000 (19:37 +0300)
committerEric Blake <eblake@redhat.com>
Fri, 12 Feb 2021 18:10:11 +0000 (12:10 -0600)
To not interfere with other qemu_nbd_popen() calls in same test.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210205163720.887197-8-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
tests/qemu-iotests/iotests.py

index 00be68eca3e2eed29fe399a2459801c6178147ef..4e758308f24710fe32141692fc7dfd0fae728056 100644 (file)
@@ -296,7 +296,9 @@ def qemu_nbd_list_log(*args: str) -> str:
 @contextmanager
 def qemu_nbd_popen(*args):
     '''Context manager running qemu-nbd within the context'''
-    pid_file = file_path("pid")
+    pid_file = file_path("qemu_nbd_popen-nbd-pid-file")
+
+    assert not os.path.exists(pid_file)
 
     cmd = list(qemu_nbd_args)
     cmd.extend(('--persistent', '--pid-file', pid_file))
@@ -314,6 +316,8 @@ def qemu_nbd_popen(*args):
             time.sleep(0.01)
         yield
     finally:
+        if os.path.exists(pid_file):
+            os.remove(pid_file)
         log('Kill NBD server')
         p.kill()
         p.wait()