From 6d4827b5ff53be563c3c43d7e56bd31e46f6d814 Mon Sep 17 00:00:00 2001 From: Saravanan D Date: Tue, 13 Jan 2026 20:21:35 +0000 Subject: [PATCH] vmm: Add device_id field to NUMA configuration Add an optional device_id string field to NumaConfig for identifying PCI devices associated with a NUMA node. This is used by the Generic Initiator support to map devices to their proximity domain. Update OpenAPI spec (cloud-hypervisor.yaml) to include the new device_id field in the NumaConfig schema. The device_id is optional and parsed from the --numa parameter: --numa "device_id=,distances=[...],..." The optional field is accepted but not used. Signed-off-by: Saravanan D --- arch/src/lib.rs | 1 + vmm/src/api/openapi/cloud-hypervisor.yaml | 2 ++ vmm/src/config.rs | 5 +++++ vmm/src/vm_config.rs | 2 ++ 4 files changed, 10 insertions(+) diff --git a/arch/src/lib.rs b/arch/src/lib.rs index a7c0ffdca..c1c197366 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -120,6 +120,7 @@ pub struct NumaNode { pub pci_segments: Vec, pub distances: BTreeMap, pub memory_zones: Vec, + pub device_id: Option, } pub type NumaNodes = BTreeMap; diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index 1fa3d9b51..d1c67c97f 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -1203,6 +1203,8 @@ components: items: type: integer format: int32 + device_id: + type: string VmResize: type: object diff --git a/vmm/src/config.rs b/vmm/src/config.rs index af9c4ce9a..3244d1bc0 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -2185,6 +2185,7 @@ impl VsockConfig { impl NumaConfig { pub const SYNTAX: &'static str = "Settings related to a given NUMA node \ \"guest_numa_id=,cpus=,distances=,\ + device_id=,\ memory_zones=,\ pci_segments=\""; @@ -2194,6 +2195,7 @@ impl NumaConfig { .add("guest_numa_id") .add("cpus") .add("distances") + .add("device_id") .add("memory_zones") .add("pci_segments"); @@ -2222,6 +2224,7 @@ impl NumaConfig { }) .collect() }); + let device_id = parser.get("device_id"); let memory_zones = parser .convert::("memory_zones") .map_err(Error::ParseNuma)? @@ -2234,6 +2237,7 @@ impl NumaConfig { guest_numa_id, cpus, distances, + device_id, memory_zones, pci_segments, }) @@ -4118,6 +4122,7 @@ mod unit_tests { guest_numa_id: 0, cpus: None, distances: None, + device_id: None, memory_zones: None, pci_segments: None, } diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs index 954ab16fc..e0e74cb4a 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -685,6 +685,8 @@ pub struct NumaConfig { pub memory_zones: Option>, #[serde(default)] pub pci_segments: Option>, + #[serde(default)] + pub device_id: Option, } /// Errors describing a misconfigured payload, i.e., a configuration that