From 66382328153fecf11d81fb60f8663f89382926b6 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 22 Nov 2024 10:37:06 +0100 Subject: [PATCH] Include machine name in virtiofsd unit name If the same directory is shared across multiple guests, we end up with duplicate unit names even though we need separate virtiofsd instances. Let's fix this by including the machine name in the virtiofsd unit name so that the unit names will be unique across guests. --- mkosi/qemu.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mkosi/qemu.py b/mkosi/qemu.py index 058de72d4..4b5889a1a 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -328,9 +328,6 @@ def start_virtiofsd( name: Optional[str] = None, selinux: bool = False, ) -> Iterator[Path]: - if name is None: - name = systemd_escape(config, directory, path=True) - virtiofsd = find_virtiofsd(root=config.tools(), extra=config.extra_search_paths) if virtiofsd is None: die("virtiofsd must be installed to boot directory images or use RuntimeTrees= with mkosi qemu") @@ -383,9 +380,13 @@ def start_virtiofsd( # We want RuntimeBuildSources= and RuntimeTrees= to do the right thing even when running mkosi qemu # as root without the source directories necessarily being owned by root. We achieve this by running # virtiofsd as the owner of the source directory and then mapping that uid to root. + if not name: + name = f"{config.machine_or_name()}-{systemd_escape(config, directory, path=True)}" + else: + name = systemd_escape(config, name) name = f"mkosi-virtiofsd-{name}" - description = f"virtiofsd for {directory}" + description = f"virtiofsd for machine {config.machine_or_name()} for {directory}" scope = [] if st: scope = scope_cmd(name=name, description=description, user=st.st_uid, group=st.st_gid)