2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

Add KVM CPU mode to vm.othersettings (see issue #4182)

Initial patch by @ajw1980
This commit is contained in:
Markus Hilger 2019-12-05 12:07:24 +01:00
parent 97f973fc2b
commit 98f111538b
2 changed files with 12 additions and 1 deletions

View File

@ -226,7 +226,7 @@ qq{ link,ro - The file is readonly, and will be placed in tmpfs on the booted no
'vncport' => 'Tracks the current VNC display port (currently not meant to be set',
'textconsole' => 'Tracks the Psuedo-TTY that maps to the serial port or console of a VM',
'powerstate' => "This flag is used by xCAT to track the last known power state of the VM.",
'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B<virsh nodedev-list> on the host.",
'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu mode use either:'cpumode:host-passthrough' or 'cpumode:host-model'. This improves performance on x86 VMs significantly. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0', the value for PCI device format also can be like:'devpassthrough:0001:01:00.1', the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B<virsh nodedev-list> on the host.",
'guestostype' => "This allows administrator to specify an identifier for OS to pass through to virtualization stack. Normally this should be ignored as xCAT will translate from nodetype.os rather than requiring this field be used\n",
'beacon' => "This flag is used by xCAT to track the state of the identify LED with respect to the VM.",
'datacenter' => "Optionally specify a datacenter for the VM to exist in (only applicable to VMWare)",

View File

@ -730,6 +730,7 @@ sub build_xmldesc {
my %cpupinhash;
my @passthrudevices;
my $memnumanodes;
my $cpumode;
my $advsettings = undef;
if (defined $confdata->{vm}->{$node}->[0]->{othersettings}) {
$advsettings = $confdata->{vm}->{$node}->[0]->{othersettings};
@ -740,6 +741,7 @@ sub build_xmldesc {
#cpu pining: "vcpupin:<physical cpu set>"
#pci passthrough: "devpassthrough:<pci device name1>,<pci device name2>..."
#memory binding: "membind:<numa node set>"
#cpu mode: "cpumode:<host-model|host-passthrough>"
if ($advsettings) {
my @tmp_array = split ";", $advsettings;
foreach (@tmp_array) {
@ -762,6 +764,9 @@ sub build_xmldesc {
$memnumanodes = $1;
}
if (/cpumode:(.*)/) {
$cpumode = $1;
}
}
}
@ -779,6 +784,12 @@ sub build_xmldesc {
$xtree{vcpu}->{cpuset} =~ s/\"\'//g;
}
if (defined $cpumode) {
if ($cpumode eq 'host-passthrough' or $cpumode eq 'host-model') {
$xtree{cpu}->{mode} = $cpumode;
}
}
#prepare the xml hash for pci passthrough
my @prdevarray;
foreach my $devname (@passthrudevices) {