From: Gregory Price Date: Tue, 23 Sep 2025 12:30:44 +0000 (-0400) Subject: config / qemu: add cxl config option X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0c4019878e509cdf74d9d20edc8eaf367ac094a;p=thirdparty%2Fmkosi.git config / qemu: add cxl config option Add machine `cxl=on` option for x86 and arm machines. Signed-off-by: Gregory Price --- diff --git a/mkosi/config.py b/mkosi/config.py index 01ff458f4..bec0d2fb5 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -575,6 +575,9 @@ class Architecture(StrEnum): def supports_hpet(self) -> bool: return self.is_x86_variant() + def supports_cxl(self) -> bool: + return self.is_x86_variant() or self.is_arm_variant() + def can_kvm(self) -> bool: return self == Architecture.native() or ( Architecture.native() == Architecture.x86_64 and self == Architecture.x86 @@ -2118,6 +2121,7 @@ class Config: ram: int maxmem: int kvm: ConfigFeature + cxl: bool vsock: ConfigFeature vsock_cid: int tpm: ConfigFeature @@ -4134,6 +4138,15 @@ SETTINGS: list[ConfigSetting[Any]] = [ compat_names=("QemuKvm",), scope=SettingScope.main, ), + ConfigSetting( + dest="cxl", + name="CXL", + metavar="BOOLEAN", + section="Runtime", + parse=config_parse_boolean, + help="Enable CXL device support", + scope=SettingScope.main, + ), ConfigSetting( dest="vsock", name="VSock", @@ -5635,6 +5648,7 @@ def summary(config: Config) -> str: RAM: {format_bytes(config.ram)} MaxMem: {format_bytes_or_none(config.maxmem)} KVM: {config.kvm} + CXL: {config.cxl} VSock: {config.vsock} VSock Connection ID: {VsockCID.format(config.vsock_cid)} TPM: {config.tpm} diff --git a/mkosi/qemu.py b/mkosi/qemu.py index e7228e2a5..c3d3a7b2d 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -1227,6 +1227,8 @@ def run_qemu(args: Args, config: Config) -> None: machine += f",smm={'on' if firmware == Firmware.uefi_secure_boot else 'off'}" if shm: machine += ",memory-backend=mem" + if config.cxl and config.architecture.supports_cxl(): + machine += ",cxl=on" if config.architecture.supports_hpet(): machine += ",hpet=off" diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index ccfbcc72c..320a73a33 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1752,6 +1752,10 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, : Configures whether KVM acceleration should be used when booting a virtual machine. Takes a boolean value or `auto`. Defaults to `auto`. +`CXL=`, `--cxl=` +: Configures whether CXL devices are enabled for a given machine. Only valid if the architecture + supports cxl. Takes a boolean value. Defaults to `false`. + `VSock=`, `--vsock=` : Configures whether to provision a vsock when booting a virtual machine. Takes a boolean value or `auto`. Defaults to `auto`. diff --git a/tests/test_json.py b/tests/test_json.py index f8a01ff39..c858d4eee 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -131,6 +131,7 @@ def test_config() -> None: "BuildSubdirectory": "abc/abc", "CDROM": false, "CPUs": 2, + "CXL": false, "CacheDirectory": "/is/this/the/cachedir", "CacheKey": "qed", "CacheOnly": "always", @@ -506,6 +507,7 @@ def test_config() -> None: key=None, keymap="wow, so much keymap", kvm=ConfigFeature.auto, + cxl=False, linux=None, local_mirror=None, locale_messages="",