From 98f111538b680dae4955ac27875e55a242b80eee Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Thu, 5 Dec 2019 12:07:24 +0100 Subject: [PATCH] Add KVM CPU mode to vm.othersettings (see issue #4182) Initial patch by @ajw1980 --- perl-xCAT/xCAT/Schema.pm | 2 +- xCAT-server/lib/xcat/plugins/kvm.pm | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index c456a533f..0fbc23d1f 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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 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 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)", diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 02fb6e385..8a75d39dc 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -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:" #pci passthrough: "devpassthrough:,..." #memory binding: "membind:" + #cpu mode: "cpumode:" 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) {