Skip to content

Commit

Permalink
Include machine name in virtiofsd unit name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DaanDeMeyer committed Nov 22, 2024
1 parent a86d3dd commit 6638232
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mkosi/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6638232

Please sign in to comment.