vmm: Introduce new CPU option to set maximum physical bits

In order to let the user choose maximum address space size, this patch
introduces a new option `max_phys_bits` to the `--cpus` parameter.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-10-13 09:17:42 +02:00
parent c97824ab76
commit 52ad78886c
3 changed files with 18 additions and 4 deletions

View File

@ -97,7 +97,8 @@ fn create_app<'a, 'b>(
.long("cpus")
.help(
"boot=<boot_vcpus>,max=<max_vcpus>,\
topology=<threads_per_core>:<cores_per_die>:<dies_per_package>:<packages>,kvm_hyperv=on|off",
topology=<threads_per_core>:<cores_per_die>:<dies_per_package>:<packages>,\
kvm_hyperv=on|off,max_phys_bits=<maximum_number_of_physical_bits>",
)
.default_value(&default_vcpus)
.group("vm-config"),
@ -133,8 +134,10 @@ fn create_app<'a, 'b>(
.arg(
Arg::with_name("kernel")
.long("kernel")
.help("Path to loaded kernel. This may be a kernel or firmware that supports a PVH \
entry point, a vmlinux ELF file or a Linux bzImage or achitecture equivalent")
.help(
"Path to loaded kernel. This may be a kernel or firmware that supports a PVH \
entry point, a vmlinux ELF file or a Linux bzImage or achitecture equivalent",
)
.takes_value(true)
.group("vm-config"),
)
@ -545,6 +548,7 @@ mod unit_tests {
max_vcpus: 1,
topology: None,
kvm_hyperv: false,
max_phys_bits: None,
},
memory: MemoryConfig {
size: 536_870_912,

View File

@ -469,6 +469,8 @@ components:
type: integer
topology:
$ref: '#/components/schemas/CpuTopology'
max_phys_bits:
type: integer
MemoryZoneConfig:
required:

View File

@ -320,6 +320,8 @@ pub struct CpusConfig {
pub topology: Option<CpuTopology>,
#[serde(default)]
pub kvm_hyperv: bool,
#[serde(default)]
pub max_phys_bits: Option<u8>,
}
impl CpusConfig {
@ -329,7 +331,8 @@ impl CpusConfig {
.add("boot")
.add("max")
.add("topology")
.add("kvm_hyperv");
.add("kvm_hyperv")
.add("max_phys_bits");
parser.parse(cpus).map_err(Error::ParseCpus)?;
let boot_vcpus: u8 = parser
@ -346,12 +349,16 @@ impl CpusConfig {
.map_err(Error::ParseCpus)?
.unwrap_or(Toggle(false))
.0;
let max_phys_bits = parser
.convert::<u8>("max_phys_bits")
.map_err(Error::ParseCpus)?;
Ok(CpusConfig {
boot_vcpus,
max_vcpus,
topology,
kvm_hyperv,
max_phys_bits,
})
}
}
@ -363,6 +370,7 @@ impl Default for CpusConfig {
max_vcpus: DEFAULT_VCPUS,
topology: None,
kvm_hyperv: false,
max_phys_bits: None,
}
}
}