[pve-devel] [PATCH 1/3] enable x2apic by default for kvm machines
Alexandre Derumier
aderumier at odiso.com
Tue Jul 9 08:57:32 CEST 2013
This reduce context switch with multicore guests.
Even if the host cpu don't have x2apic, it's working because qemu have an virtual x2apic implementation for guest.
We need in-kernel irqchip support for this, which is enable for kvm guest since qemu 1.3.
(I don't enable it if nokvm param is set)
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 31d8103..196ad0a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2225,6 +2225,7 @@ sub config_to_command {
my $globalFlags = [];
my $machineFlags = [];
my $rtcFlags = [];
+ my $cpuFlags = [];
my $devices = [];
my $pciaddr = '';
my $bridges = {};
@@ -2313,16 +2314,6 @@ sub config_to_command {
push @$cmd, '-name', $vmname;
- my $sockets = 1;
- $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
- $sockets = $conf->{sockets} if $conf->{sockets};
-
- my $cores = $conf->{cores} || 1;
-
- push @$cmd, '-smp', "sockets=$sockets,cores=$cores";
-
- push @$cmd, '-cpu', $conf->{cpu} if $conf->{cpu};
-
push @$cmd, '-nodefaults';
my $bootorder = $conf->{boot} || $confdesc->{boot}->{default};
@@ -2395,6 +2386,20 @@ sub config_to_command {
push @$rtcFlags, 'base=localtime';
}
+ my $sockets = 1;
+ $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
+ $sockets = $conf->{sockets} if $conf->{sockets};
+
+ my $cores = $conf->{cores} || 1;
+ push @$cmd, '-smp', "sockets=$sockets,cores=$cores";
+
+ my $cpu = $nokvm ? "qemu64":"kvm64";
+ $cpu = $conf->{cpu} if $conf->{cpu};
+
+ push @$cpuFlags , '+x2apic' if !$nokvm;
+
+ push @$cmd, '-cpu', $cpu.",".join(',', @$cpuFlags);
+
push @$cmd, '-S' if $conf->{freeze};
# set keyboard layout
--
1.7.10.4
More information about the pve-devel
mailing list