logging.debug(f"- {k}={v}")
+def make_nocow(config: Config, path: Path) -> None:
+ run(
+ ["chattr", "+C", workdir(path)],
+ check=False,
+ stderr=subprocess.DEVNULL if not ARG_DEBUG.get() else None,
+ sandbox=config.sandbox(binary="chattr", options=["--bind", path, workdir(path)]),
+ )
+
+
@contextlib.contextmanager
def start_journal_remote(config: Config, sockfd: int) -> Iterator[None]:
assert config.forward_journal
# at the same time.
d.mkdir(exist_ok=True, parents=True)
# Make sure COW is disabled so systemd-journal-remote doesn't complain on btrfs filesystems.
- run(["chattr", "+C", d], check=False, stderr=subprocess.DEVNULL if not ARG_DEBUG.get() else None)
+ make_nocow(config, d)
INVOKING_USER.chown(d)
with tempfile.NamedTemporaryFile(mode="w", prefix="mkosi-journal-remote-config-") as f:
if "No_COW" in attr:
tmp.touch()
- run(
- ["chattr", "+C", workdir(tmp)],
- sandbox=config.sandbox(binary="chattr", options=["--bind", tmp, workdir(tmp)]),
- )
+ make_nocow(config, tmp)
copy_tree(
src,
@contextlib.contextmanager
-def finalize_drive(drive: QemuDrive) -> Iterator[Path]:
+def finalize_drive(config: Config, drive: QemuDrive) -> Iterator[Path]:
with tempfile.NamedTemporaryFile(
- dir=drive.directory or "/var/tmp", prefix=f"mkosi-drive-{drive.id}"
+ dir=drive.directory or "/var/tmp",
+ prefix=f"mkosi-drive-{drive.id}",
) as file:
+ make_nocow(config, Path(file.name))
file.truncate(drive.size)
yield Path(file.name)
]
for _, drives in groupby(config.qemu_drives, key=lambda d: d.file_id):
- file = stack.enter_context(finalize_drive(drives[0]))
+ file = stack.enter_context(finalize_drive(config, drives[0]))
for drive in drives:
arg = f"if=none,id={drive.id},file={file},format=raw,file.locking=off"