[pve-devel] [PATCH qemu-server v2 3/3] Fix #1125. Check for KVM support before starting VM

Philip Abernethy p.abernethy at proxmox.com
Mon Aug 21 11:47:18 CEST 2017


Moved the check to the beginning of the function.
VMs configured to use KVM won't start if KVM is not available.
VMs not configured to use KVM will start regardless.
---
 PVE/QemuServer.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index d6ddb1d..2aafc42 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2837,6 +2837,8 @@ sub config_to_command {
     my $winversion = windows_version($ostype);
     my $kvm = $conf->{kvm} // 1;
 
+    die "KVM virtualisation configured, but not available. Either disable in VM configuration or enable in BIOS.\n" if (!$cpuinfo->{hvm} && $kvm);
+
     if ($kvmver =~ m/^(\d+)\.(\d+)$/) {
 	$vernum = $1*1000000+$2*1000;
     } elsif ($kvmver =~ m/^(\d+)\.(\d+)\.(\d+)$/) {
@@ -3106,8 +3108,6 @@ sub config_to_command {
 
     if (!$kvm) {
 	push @$machineFlags, 'accel=tcg';
-    } else {
-	die "No accelerator found!\n" if !$cpuinfo->{hvm};
     }
 
     if ($machine_type) {
-- 
2.11.0





More information about the pve-devel mailing list