From 9a6a2e768a57307131bb349990fde8b3de596087 Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Tue, 21 Nov 2023 13:10:37 +0100 Subject: [PATCH 1/2] Makefile: improve KVM detection Instead of checking for the KVM module, check for write access to /dev/kvm. Signed-off-by: Pawel Wieczorkiewicz --- Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a422a74d..a9a40104 100644 --- a/Makefile +++ b/Makefile @@ -249,19 +249,16 @@ clean: # Check whether we can use kvm for qemu ifeq ($(SYSTEM),LINUX) ifneq ($(USE_KVM), false) # you can hard-disable KVM use with the USE_KVM environment variable -HAVE_KVM=$(shell lsmod | awk '/^kvm / {print $$1}') +HAVE_KVM=$(shell test -w /dev/kvm && echo kvm) endif # USE_KVM endif # SYSTEM == LINUX # Set qemu parameters ifeq ($(SYSTEM)$(HAVE_KVM),LINUXkvm) -QEMU_PARAMS := -cpu host +QEMU_PARAMS := -cpu host -enable-kvm else QEMU_PARAMS := -cpu max endif -ifeq ($(HAVE_KVM), kvm) -QEMU_PARAMS += -enable-kvm -endif # HAVE_KVM QEMU_PARAMS += -m 128 QEMU_PARAMS += -serial stdio QEMU_PARAMS += -smp cpus=2 From eab821b680dd72e91922db52a3a83006de4c392f Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Tue, 21 Nov 2023 13:12:19 +0100 Subject: [PATCH 2/2] Makefile: handle variable QEMU settings in .qemu_config Signed-off-by: Pawel Wieczorkiewicz --- .qemu_config | 2 ++ Makefile | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .qemu_config diff --git a/.qemu_config b/.qemu_config new file mode 100644 index 00000000..72396bb6 --- /dev/null +++ b/.qemu_config @@ -0,0 +1,2 @@ +QEMU_RAM=128 +QEMU_CPUS=2 diff --git a/Makefile b/Makefile index a9a40104..2ad5a9ad 100644 --- a/Makefile +++ b/Makefile @@ -254,14 +254,17 @@ endif # USE_KVM endif # SYSTEM == LINUX # Set qemu parameters +QEMU_CONFIG := $(KTF_ROOT)/.qemu_config +include $(QEMU_CONFIG) + ifeq ($(SYSTEM)$(HAVE_KVM),LINUXkvm) QEMU_PARAMS := -cpu host -enable-kvm else QEMU_PARAMS := -cpu max endif -QEMU_PARAMS += -m 128 +QEMU_PARAMS += -m $(QEMU_RAM) QEMU_PARAMS += -serial stdio -QEMU_PARAMS += -smp cpus=2 +QEMU_PARAMS += -smp cpus=$(QEMU_CPUS) QEMU_PARAMS_NOGFX := -display none -vga none -vnc none QEMU_PARAMS_GFX := $(QEMU_PARAMS) QEMU_PARAMS += $(QEMU_PARAMS_NOGFX)