]> Git Repo - qemu.git/commitdiff
python/machine: add instance disambiguator to default nickname
authorJohn Snow <[email protected]>
Thu, 18 Nov 2021 20:46:16 +0000 (15:46 -0500)
committerJohn Snow <[email protected]>
Mon, 22 Nov 2021 23:40:59 +0000 (18:40 -0500)
If you create two instances of QEMUMachine(), they'll both create the
same nickname by default -- which is not that helpful.

Luckily, they'll both create unique temporary directories ... but due to
user configuration, they may share logging and sockfile directories,
meaning two instances can collide. The Python logging will also be quite
confusing, with no differentiation between the two instances.

Add an instance disambiguator (The memory address of the instance) to
the default nickname to foolproof this in all cases.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Willian Rampazzo <[email protected]>
Message-id: 20211118204620.1897674[email protected]
Signed-off-by: John Snow <[email protected]>
python/qemu/machine/machine.py

index ea9e07805df10a57115dace06885b8d0b82ff581..ad529fd92a6022150fd0156d005d6c7175565574 100644 (file)
@@ -133,7 +133,7 @@ class QEMUMachine:
         self._wrapper = wrapper
         self._qmp_timer = qmp_timer
 
-        self._name = name or "qemu-%d" % os.getpid()
+        self._name = name or f"qemu-{os.getpid()}-{id(self):02x}"
         self._temp_dir: Optional[str] = None
         self._base_temp_dir = base_temp_dir
         self._sock_dir = sock_dir
This page took 0.027229 seconds and 4 git commands to generate.