]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
config / qemu: add cxl config option 3910/head
authorGregory Price <gourry@gourry.net>
Tue, 23 Sep 2025 12:30:44 +0000 (08:30 -0400)
committerGregory Price <gourry@gourry.net>
Tue, 23 Sep 2025 16:25:25 +0000 (12:25 -0400)
Add machine `cxl=on` option for x86 and arm machines.

Signed-off-by: Gregory Price <gourry@gourry.net>
mkosi/config.py
mkosi/qemu.py
mkosi/resources/man/mkosi.1.md
tests/test_json.py

index 01ff458f4fdc05e162251fcfcc0a352672bece0d..bec0d2fb5a7a2f225624e0a44b61837528a525b2 100644 (file)
@@ -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}
index e7228e2a5834aa91363d042aa016eab755fa04b3..c3d3a7b2d32e756a653fb1708305b147f52ab9cb 100644 (file)
@@ -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"
 
index ccfbcc72cfe6e9875725b826305b4b9654b4b1a3..320a73a330a2d3454bd9af7e338a0e8348191908 100644 (file)
@@ -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`.
index f8a01ff39abde10a1597c91348f2f16c03b401a6..c858d4eee6545a41bec60e2559d4e9cec184add4 100644 (file)
@@ -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="",