Skip to content

Commit

Permalink
iotests.py: qemu_nbd_popen: remove pid file after use
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and ebblake committed Feb 12, 2021
1 parent 46bd6f8 commit 3f7db41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/qemu-iotests/iotests.py
Expand Up @@ -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))
Expand All @@ -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()
Expand Down

0 comments on commit 3f7db41

Please sign in to comment.