From: Daan De Meyer Date: Thu, 19 Dec 2024 10:09:36 +0000 (+0100) Subject: Rename [Host] section to [Runtime] section X-Git-Tag: v25~108^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3285%2Fhead;p=thirdparty%2Fmkosi.git Rename [Host] section to [Runtime] section [Host] is not a very descriptive name for the settings in this section. As all these settings affect the behavior of mkosi shell, mkosi qemu, mkosi boot or mkosi vmspawn, let's rename the section to [Runtime]. We make sure to still parse [Host] as well to keep backwards compat. --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f45362df..4a8f7f83d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,7 +177,7 @@ jobs: [Build] Environment=SYSTEMD_REPART_MKFS_OPTIONS_EROFS="--quiet" - [Host] + [Runtime] QemuKvm=yes EOF diff --git a/mkosi.conf b/mkosi.conf index 1e6da3df0..8e62fb3d7 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -49,5 +49,5 @@ KernelCommandLine= KernelModulesInitrdExclude=.* KernelModulesInitrdInclude=default -[Host] +[Runtime] QemuMem=4G diff --git a/mkosi.conf.d/15-memory.conf b/mkosi.conf.d/15-memory.conf index f260df561..6db5bb1e4 100644 --- a/mkosi.conf.d/15-memory.conf +++ b/mkosi.conf.d/15-memory.conf @@ -5,5 +5,5 @@ Format=|esp Format=|uki Format=|cpio -[Host] +[Runtime] QemuMem=8G diff --git a/mkosi/config.py b/mkosi/config.py index a86d90914..a74885cb4 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -3436,7 +3436,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ name="NSpawnSettings", long="--settings", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(), paths=("mkosi.nspawn",), help="Add in .nspawn settings file", @@ -3444,7 +3444,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="ephemeral", metavar="BOOL", - section="Host", + section="Runtime", parse=config_parse_boolean, help=( "If specified, the container/VM is run with a temporary snapshot of the output " @@ -3456,7 +3456,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="credentials", long="--credential", metavar="NAME=VALUE", - section="Host", + section="Runtime", parse=config_make_dict_parser(delimiter=" ", parse=parse_key_value, allow_paths=True, unescape=True), help="Pass a systemd credential to systemd-nspawn or qemu", paths=("mkosi.credentials",), @@ -3464,7 +3464,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="kernel_command_line_extra", metavar="OPTIONS", - section="Host", + section="Runtime", parse=config_make_list_parser(delimiter=" "), help="Append extra entries to the kernel command line when booting the image", ), @@ -3472,27 +3472,27 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="runtime_trees", long="--runtime-tree", metavar="SOURCE:[TARGET]", - section="Host", + section="Runtime", parse=config_make_list_parser(delimiter=",", parse=make_tree_parser(absolute=False)), help="Additional mounts to add when booting the image", ), ConfigSetting( dest="runtime_size", metavar="SIZE", - section="Host", + section="Runtime", parse=config_parse_bytes, help="Grow disk images to the specified size before booting them", ), ConfigSetting( dest="runtime_scratch", metavar="FEATURE", - section="Host", + section="Runtime", parse=config_parse_feature, help="Mount extra scratch space to /var/tmp", ), ConfigSetting( dest="runtime_network", - section="Host", + section="Runtime", parse=config_make_enum_parser(Network), choices=Network.choices(), help="Set networking backend to use when booting the image", @@ -3501,14 +3501,14 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="runtime_build_sources", metavar="BOOL", - section="Host", + section="Runtime", parse=config_parse_boolean, help="Mount build sources and build directory in /work when booting the image", ), ConfigSetting( dest="runtime_home", metavar="BOOL", - section="Host", + section="Runtime", parse=config_parse_boolean, help="Mount current home directory to /root when booting the image", ), @@ -3516,14 +3516,14 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="unit_properties", long="--unit-property", metavar="PROPERTY", - section="Host", + section="Runtime", parse=config_make_list_parser(delimiter=" ", unescape=True), help="Set properties on the scopes spawned by systemd-nspawn or systemd-run", ), ConfigSetting( dest="ssh_key", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(secret=True), paths=("mkosi.key",), help="Private key for use with mkosi ssh in PEM format", @@ -3531,7 +3531,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="ssh_certificate", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(), paths=("mkosi.crt",), help="Certificate for use with mkosi ssh in X509 format", @@ -3539,7 +3539,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="vmm", name="VirtualMachineMonitor", - section="Host", + section="Runtime", choices=Vmm.choices(), parse=config_make_enum_parser(Vmm), default=Vmm.qemu, @@ -3548,13 +3548,13 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="machine", metavar="NAME", - section="Host", + section="Runtime", help="Set the machine name to use when booting the image", ), ConfigSetting( dest="forward_journal", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(required=False), help="Set the path used to store forwarded machine journals", ), @@ -3564,7 +3564,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ compat_longs=("--sysupdate-dir",), metavar="PATH", name="SysupdateDirectory", - section="Host", + section="Runtime", parse=config_make_path_parser(), paths=("mkosi.sysupdate",), help="Directory containing systemd-sysupdate transfer definitions", @@ -3573,14 +3573,14 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_gui", metavar="BOOL", nargs="?", - section="Host", + section="Runtime", parse=config_parse_boolean, help="Start QEMU in graphical mode", ), ConfigSetting( dest="qemu_smp", metavar="SMP", - section="Host", + section="Runtime", parse=config_parse_number, default=1, help="Configure guest's SMP settings", @@ -3588,7 +3588,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="qemu_mem", metavar="MEM", - section="Host", + section="Runtime", parse=config_parse_bytes, default=parse_bytes("2G"), help="Configure guest's RAM size", @@ -3597,7 +3597,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_kvm", metavar="FEATURE", nargs="?", - section="Host", + section="Runtime", parse=config_parse_feature, help="Configure whether to use KVM or not", ), @@ -3605,7 +3605,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_vsock", metavar="FEATURE", nargs="?", - section="Host", + section="Runtime", parse=config_parse_feature, help="Configure whether to use qemu with a vsock or not", ), @@ -3614,7 +3614,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ name="QemuVsockConnectionId", long="--qemu-vsock-cid", metavar="NUMBER|auto|hash", - section="Host", + section="Runtime", parse=config_parse_vsock_cid, default=QemuVsockCID.auto, help="Specify the VSock connection ID to use", @@ -3623,7 +3623,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_swtpm", metavar="FEATURE", nargs="?", - section="Host", + section="Runtime", parse=config_parse_feature, help="Configure whether to use qemu with swtpm or not", ), @@ -3631,7 +3631,7 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_cdrom", metavar="BOOLEAN", nargs="?", - section="Host", + section="Runtime", parse=config_parse_boolean, help="Attach the image as a CD-ROM to the virtual machine", ), @@ -3639,13 +3639,13 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_removable", metavar="BOOLEAN", nargs="?", - section="Host", + section="Runtime", parse=config_parse_boolean, help="Attach the image as a removable drive to the virtual machine", ), ConfigSetting( dest="qemu_firmware", - section="Host", + section="Runtime", parse=config_make_enum_parser(QemuFirmware), default=QemuFirmware.auto, help="Set qemu firmware to use", @@ -3654,14 +3654,14 @@ SETTINGS: list[ConfigSetting[Any]] = [ ConfigSetting( dest="qemu_firmware_variables", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(constants=("custom", "microsoft")), help="Set the path to the qemu firmware variables file to use", ), ConfigSetting( dest="qemu_kernel", metavar="PATH", - section="Host", + section="Runtime", parse=config_make_path_parser(), help="Specify the kernel to use for qemu direct kernel boot", ), @@ -3669,14 +3669,14 @@ SETTINGS: list[ConfigSetting[Any]] = [ dest="qemu_drives", long="--qemu-drive", metavar="DRIVE", - section="Host", + section="Runtime", parse=config_make_list_parser(delimiter=" ", parse=parse_drive), help="Specify a qemu drive that mkosi should create and pass to qemu", ), ConfigSetting( dest="qemu_args", metavar="ARGS", - section="Host", + section="Runtime", parse=config_make_list_parser(delimiter=" ", unescape=True), # Suppress the command line option because it's already possible to pass qemu args as normal # arguments. @@ -4302,7 +4302,8 @@ class ParseContext: files += [abs_path] for section, k, v in parse_ini( - path, only_sections=self.only_sections or {s.section for s in SETTINGS} + path, + only_sections=self.only_sections or {s.section for s in SETTINGS} | {"Host"}, ): if not k and not v: continue @@ -4440,7 +4441,7 @@ def parse_config( # build the previous image from there instead of parsing configuration files, except for the Host # section settings which we allow changing without requiring a rebuild of the image. for s in SETTINGS: - if s.section in ("Include", "Host"): + if s.section in ("Include", "Runtime"): continue if hasattr(context.cli, s.dest) and getattr(context.cli, s.dest) != getattr(prev, s.dest): @@ -4452,7 +4453,7 @@ def parse_config( if hasattr(context.config, s.dest): delattr(context.config, s.dest) - context.only_sections = ("Include", "Host") + context.only_sections = ("Include", "Runtime", "Host") else: context.only_sections = tuple(only_sections) prev = None diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 5ec136848..2655e32cb 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1556,7 +1556,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, Currently, setting a proxy client key is only supported when `dnf` or `dnf5` is used to build the image. -### [Host] Section +### [Runtime] Section (previously known as the [Host] section) `NSpawnSettings=`, `--settings=` : Specifies a `.nspawn` settings file for `systemd-nspawn` to use in @@ -1685,7 +1685,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, **Example usage:** ```ini - [Host] + [Runtime] QemuDrives=btrfs:10G ext4:20G QemuArgs=-device nvme,serial=btrfs,drive=btrfs diff --git a/tests/test_config.py b/tests/test_config.py index f572739b2..a7717ff0d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -110,7 +110,7 @@ def test_parse_config(tmp_path: Path) -> None: Format=cpio ImageId=base - [Host] + [Runtime] Credentials=my.cred=my.value """ ) @@ -356,7 +356,7 @@ def test_profiles(tmp_path: Path) -> None: [Distribution] Distribution=fedora - [Host] + [Runtime] QemuKvm=yes """ ) @@ -425,8 +425,6 @@ def test_override_default(tmp_path: Path) -> None: """\ [Build] Environment=MY_KEY=MY_VALUE - - [Host] ToolsTree=default """ )