From: Daan De Meyer Date: Sat, 16 Mar 2024 19:32:00 +0000 (+0100) Subject: Introduce apply_runtime_size() X-Git-Tag: v23~85^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7b3e1b69b99b1e4ee19c8cc1fd913d7b7fee4f0;p=thirdparty%2Fmkosi.git Introduce apply_runtime_size() --- diff --git a/mkosi/qemu.py b/mkosi/qemu.py index f64748140..218931fa7 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -505,6 +505,24 @@ def finalize_firmware_variables(config: Config, ovmf: OvmfConfig, stack: context return Path(ovmf_vars.name), ovmf_vars_format +def apply_runtime_size(config: Config, image: Path) -> None: + if config.output_format != OutputFormat.disk or not config.runtime_size: + return + + run( + [ + "systemd-repart", + "--definitions", "", + "--no-pager", + f"--size={config.runtime_size}", + "--pretty=no", + "--offline=yes", + image, + ], + sandbox=config.sandbox(mounts=[Mount(image, image)]), + ) + + def run_qemu(args: Args, config: Config) -> None: if config.output_format not in ( OutputFormat.disk, @@ -705,19 +723,7 @@ def run_qemu(args: Args, config: Config) -> None: else: fname = stack.enter_context(flock_or_die(config.output_dir_or_cwd() / config.output_with_compression)) - if config.output_format == OutputFormat.disk and config.runtime_size: - run( - [ - "systemd-repart", - "--definitions", "", - "--no-pager", - f"--size={config.runtime_size}", - "--pretty=no", - "--offline=yes", - fname, - ], - sandbox=config.sandbox(mounts=[Mount(fname, fname)]), - ) + apply_runtime_size(config, fname) if ( kernel and diff --git a/mkosi/vmspawn.py b/mkosi/vmspawn.py index d4af6f71b..d1fa71375 100644 --- a/mkosi/vmspawn.py +++ b/mkosi/vmspawn.py @@ -15,6 +15,7 @@ from mkosi.config import ( ) from mkosi.log import die from mkosi.qemu import ( + apply_runtime_size, copy_ephemeral, finalize_qemu_firmware, find_ovmf_firmware, @@ -83,19 +84,7 @@ def run_vmspawn(args: Args, config: Config) -> None: else: fname = stack.enter_context(flock_or_die(config.output_dir_or_cwd() / config.output)) - if config.output_format == OutputFormat.disk and config.runtime_size: - run( - [ - "systemd-repart", - "--definitions", "", - "--no-pager", - f"--size={config.runtime_size}", - "--pretty=no", - "--offline=yes", - fname, - ], - sandbox=config.sandbox(mounts=[Mount(fname, fname)]), - ) + apply_runtime_size(config, fname) kcl = config.kernel_command_line_extra