]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
qemu: Make sure virtiofsd sock name is unique
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 20 Sep 2023 21:30:11 +0000 (23:30 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 21 Sep 2023 11:16:27 +0000 (13:16 +0200)
We use the socket name as the tag for the virtiofs so it has to be
unique. We keep it within 36 bytes though as that's the max tag size.

mkosi/qemu.py

index 77c5187ac838f8d703c229e62b846542562ea1db..476a2a7a3182dcb01cc052fbb9cb60fd02075064 100644 (file)
@@ -168,7 +168,9 @@ def start_virtiofsd(directory: Path) -> Iterator[Path]:
         # Make sure virtiofsd is allowed to create its socket in this temporary directory.
         os.chown(state, uid, gid)
 
-        sock = Path(state) / Path("sock")
+        # Make sure we can use the socket name as a unique identifier for the fs as well but make sure it's not too
+        # long as virtiofs tag names are limited to 36 bytes.
+        sock = Path(state) / f"sock-{uuid.uuid4().hex}"[:35]
 
         virtiofsd = shutil.which("virtiofsd")
         if virtiofsd is None: