qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests/functional: Use more fine-grained locking when looking for free ports
@ 2025-08-21  9:47 Thomas Huth
  2025-08-21 10:00 ` Daniel P. Berrangé
  2025-08-25  7:30 ` Manos Pitsidianakis
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas Huth @ 2025-08-21  9:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrangé, Philippe Mathieu-Daudé

From: Thomas Huth <thuth@redhat.com>

Currently, we have one lock that is held while a test is looking for
free ports. However, we are also using different ranges for looking
for free ports nowadays (PORTS_START is based on the PID of the process),
so instead of using only one lock, we should rather use a lock per
range instead. This should help to allow running more tests in parallel.

While we're at it, also create the lock files without executable bit
(mode is 0o777 by default).

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/qemu_test/ports.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/functional/qemu_test/ports.py b/tests/functional/qemu_test/ports.py
index 631b77abf6b..81174a61532 100644
--- a/tests/functional/qemu_test/ports.py
+++ b/tests/functional/qemu_test/ports.py
@@ -23,8 +23,9 @@ class Ports():
     PORTS_END = PORTS_START + PORTS_RANGE_SIZE
 
     def __enter__(self):
-        lock_file = os.path.join(BUILD_DIR, "tests", "functional", "port_lock")
-        self.lock_fh = os.open(lock_file, os.O_CREAT)
+        lock_file = os.path.join(BUILD_DIR, "tests", "functional",
+                                 f".port_lock.{self.PORTS_START}")
+        self.lock_fh = os.open(lock_file, os.O_CREAT, mode=0o666)
         fcntl.flock(self.lock_fh, fcntl.LOCK_EX)
         return self
 
-- 
2.50.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-25  9:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-21  9:47 [PATCH] tests/functional: Use more fine-grained locking when looking for free ports Thomas Huth
2025-08-21 10:00 ` Daniel P. Berrangé
2025-08-25  7:30 ` Manos Pitsidianakis
2025-08-25  8:47   ` Thomas Huth
2025-08-25  8:51     ` Manos Pitsidianakis
2025-08-25  9:04       ` Thomas Huth
2025-08-25  9:10         ` Manos Pitsidianakis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).