[pve-devel] [PATCH 2/2] Fix #1125. Check for KVM support before starting VM

Philip Abernethy p.abernethy at proxmox.com
Wed Aug 16 18:29:04 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 88b1c5b..96e1083 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