From 3e2e8e61f734eea52604117b33017bb9c33f90f6 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 19 Nov 2017 12:39:37 +0700 Subject: [PATCH] New option: require KVM. If false, Qemu VMs will not be prevented to run without KVM. --- conf/gns3_server.conf | 2 ++ gns3server/compute/qemu/qemu_vm.py | 5 ++++- scripts/remote-install.sh | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/gns3_server.conf b/conf/gns3_server.conf index 83ab86ec..e8e98431 100644 --- a/conf/gns3_server.conf +++ b/conf/gns3_server.conf @@ -63,3 +63,5 @@ license_check = True [Qemu] ; !! Remember to add the gns3 user to the KVM group, otherwise you will not have read / write permssions to /dev/kvm !! enable_kvm = True +; Require KVM to be installed in order to start VMs +require_kvm = True \ No newline at end of file diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 41a0fb50..74ea2dc6 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1624,7 +1624,10 @@ class QemuVM(BaseNode): return False if not os.path.exists("/dev/kvm"): - raise QemuError("KVM acceleration cannot be used (/dev/kvm doesn't exist). You can turn off KVM support in the gns3_server.conf by adding enable_kvm = false to the [Qemu] section.") + if self.manager.config.get_section_config("Qemu").getboolean("require_kvm", True): + raise QemuError("KVM acceleration cannot be used (/dev/kvm doesn't exist). You can turn off KVM support in the gns3_server.conf by adding enable_kvm = false to the [Qemu] section.") + else: + return False return True return False diff --git a/scripts/remote-install.sh b/scripts/remote-install.sh index b126bf39..1ea888ca 100644 --- a/scripts/remote-install.sh +++ b/scripts/remote-install.sh @@ -212,6 +212,7 @@ report_errors = True [Qemu] enable_kvm = True +require_kvm = True EOFC chown -R gns3:gns3 /etc/gns3 @@ -298,6 +299,7 @@ report_errors = True [Qemu] enable_kvm = True +require_kvm = True EOFSERVER log "Install packages for Open VPN"