From e15dba292580f3b66d6af6fb7daf78777111dcea Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 4 Sep 2020 17:47:34 +0200 Subject: [PATCH] vmm: Rename NUMA option 'id' into 'guest_numa_id' The goal of this commit is to rename the existing NUMA option 'id' with 'guest_numa_id'. This is done without any modification to the way this option behaves. The reason for the rename is caused by the observation that all other parameters with an option called 'id' expect a string to be provided. Because in this particular case we expect a u32 representing a proximity domain from the ACPI specification, it's better to name it with a more explicit name. Signed-off-by: Sebastien Boeuf --- docs/memory.md | 40 +++++++++++------------ tests/integration.rs | 6 ++-- vmm/src/api/openapi/cloud-hypervisor.yaml | 4 +-- vmm/src/config.rs | 12 +++---- vmm/src/vm.rs | 6 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/memory.md b/docs/memory.md index 0cf06b8c6..e2252f371 100644 --- a/docs/memory.md +++ b/docs/memory.md @@ -308,7 +308,7 @@ struct NumaConfig { --numa Settings related to a given NUMA node "id=,cpus=,distances=,memory_zones=" ``` -### `id` +### `guest_numa_id` Node identifier of a guest NUMA node. This identifier must be unique, otherwise an error will be returned. @@ -320,14 +320,14 @@ Value is an unsigned integer of 32 bits. _Example_ ``` ---numa id=0 +--numa guest_numa_id=0 ``` ### `cpus` -List of virtual CPUs attached to the guest NUMA node identified by the `id` -option. This allows for describing a list of CPUs which must be seen by the -guest as belonging to the NUMA node `id`. +List of virtual CPUs attached to the guest NUMA node identified by the +`guest_numa_id` option. This allows for describing a list of CPUs which +must be seen by the guest as belonging to the NUMA node `guest_numa_id`. One can use this option for a fine grained description of the NUMA topology regarding the CPUs associated with it, which might help the guest run more @@ -348,17 +348,17 @@ _Example_ ``` --cpus boot=8 ---numa id=0,cpus=1-3:7 ---numa id=1,cpus=0:4-6 +--numa guest_numa_id=0,cpus=1-3:7 +--numa guest_numa_id=1,cpus=0:4-6 ``` ### `distances` -List of distances between the current NUMA node referred by `id` and the -destination NUMA nodes listed along with distances. This option let the user -choose the distances between guest NUMA nodes. This is important to provide an -accurate description of the way non uniform memory accesses will perform in the -guest. +List of distances between the current NUMA node referred by `guest_numa_id` +and the destination NUMA nodes listed along with distances. This option let +the user choose the distances between guest NUMA nodes. This is important to +provide an accurate description of the way non uniform memory accesses will +perform in the guest. One or more tuple of two values must be provided through this option. The first value is an unsigned integer of 32 bits as it represents the destination NUMA @@ -374,16 +374,16 @@ different distances, it can be described with the following example. _Example_ ``` ---numa id=0,distances=1@15:2@25 ---numa id=1,distances=0@15:2@20 ---numa id=2,distances=0@25:1@20 +--numa guest_numa_id=0,distances=1@15:2@25 +--numa guest_numa_id=1,distances=0@15:2@20 +--numa guest_numa_id=2,distances=0@25:1@20 ``` ### `memory_zones` -List of memory zones attached to the guest NUMA node identified by the `id` -option. This allows for describing a list of memory ranges which must be seen -by the guest as belonging to the NUMA node `id`. +List of memory zones attached to the guest NUMA node identified by the +`guest_numa_id` option. This allows for describing a list of memory ranges +which must be seen by the guest as belonging to the NUMA node `guest_numa_id`. This option can be very useful and powerful when combined with `host_numa_node` option from `--memory-zone` parameter as it allows for creating a VM with non @@ -402,6 +402,6 @@ _Example_ --memory-zone id=mem0,size=1G --memory-zone id=mem1,size=1G --memory-zone id=mem2,size=1G ---numa id=0,memory_zones=mem0:mem2 ---numa id=1,memory_zones=mem1 +--numa guest_numa_id=0,memory_zones=mem0:mem2 +--numa guest_numa_id=1,memory_zones=mem1 ``` diff --git a/tests/integration.rs b/tests/integration.rs index a52802ddf..f3ea8e8b1 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -2325,9 +2325,9 @@ mod tests { ]) .args(&[ "--numa", - "id=0,cpus=0-2,distances=1@15:2@20,memory_zones=mem0", - "id=1,cpus=3-4,distances=0@20:2@25,memory_zones=mem1", - "id=2,cpus=5,distances=0@25:1@30,memory_zones=mem2", + "guest_numa_id=0,cpus=0-2,distances=1@15:2@20,memory_zones=mem0", + "guest_numa_id=1,cpus=3-4,distances=0@20:2@25,memory_zones=mem1", + "guest_numa_id=2,cpus=5,distances=0@25:1@30,memory_zones=mem2", ]) .args(&["--kernel", guest.fw_path.as_str()]) .capture_output() diff --git a/vmm/src/api/openapi/cloud-hypervisor.yaml b/vmm/src/api/openapi/cloud-hypervisor.yaml index 0b72a5ca5..0f715a10d 100644 --- a/vmm/src/api/openapi/cloud-hypervisor.yaml +++ b/vmm/src/api/openapi/cloud-hypervisor.yaml @@ -736,10 +736,10 @@ components: NumaConfig: required: - - id + - guest_numa_id type: object properties: - id: + guest_numa_id: type: integer format: uint32 cpus: diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 9eff718b0..74296595e 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1223,7 +1223,7 @@ pub struct NumaDistance { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)] pub struct NumaConfig { #[serde(default)] - pub id: u32, + pub guest_numa_id: u32, #[serde(default)] pub cpus: Option>, #[serde(default)] @@ -1234,19 +1234,19 @@ pub struct NumaConfig { impl NumaConfig { pub const SYNTAX: &'static str = "Settings related to a given NUMA node \ - \"id=,cpus=,distances=,\ + \"guest_numa_id=,cpus=,distances=,\ memory_zones=\""; pub fn parse(numa: &str) -> Result { let mut parser = OptionParser::new(); parser - .add("id") + .add("guest_numa_id") .add("cpus") .add("distances") .add("memory_zones"); parser.parse(numa).map_err(Error::ParseNuma)?; - let id = parser - .convert::("id") + let guest_numa_id = parser + .convert::("guest_numa_id") .map_err(Error::ParseNuma)? .unwrap_or(0); let cpus = parser @@ -1270,7 +1270,7 @@ impl NumaConfig { .map(|v| v.0); Ok(NumaConfig { - id, + guest_numa_id, cpus, distances, memory_zones, diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 024ebea41..2b1d65dae 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -377,10 +377,10 @@ impl Vm { let mut numa_nodes = BTreeMap::new(); if let Some(configs) = &configs { - let node_id_list: Vec = configs.iter().map(|cfg| cfg.id).collect(); + let node_id_list: Vec = configs.iter().map(|cfg| cfg.guest_numa_id).collect(); for config in configs.iter() { - if numa_nodes.contains_key(&config.id) { + if numa_nodes.contains_key(&config.guest_numa_id) { error!("Can't define twice the same NUMA node"); return Err(Error::InvalidNumaConfig); } @@ -425,7 +425,7 @@ impl Vm { } } - numa_nodes.insert(config.id, node); + numa_nodes.insert(config.guest_numa_id, node); } }