Fix errors when try to build kvm selftests on
cover Fix errors when try to build kvm selftests on
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=~/mydir TARGETS=kvm" in tools/testing/selftests, nor
"make OUTPUT=~/mydir" in tools/testing/selftests/kvm work.
This series aims to make both work.
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specified
selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
tools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/2 kvm: selftests: Fix no directory error when OUTPUT specified
When build kvm selftests to an specified directory with
make OUTPUT=~/kvm-selftests
it encouters following error:
/usr/bin/ld: cannot open output file /home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:141:/home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test] Error 1
--- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/kvm/Makefile +1 -0
@@ -66,6 +66,7 @@ LDFLAGS += -pthread $(no-pie-option) $(pgste-option) # After inclusion, $(OUTPUT) is defined and # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ include ../lib.mk +x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS)))) STATIC_LIBS := $(OUTPUT)/libkvm.a LIBKVM_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM))
Signature · 1 line
2.20.1
shuah
maintainerRe: [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified
Quoted 5 lines · Xiaoyao Li
When build kvm selftests to an specified directory with
make OUTPUT=~/kvm-selftests
it encouters following error:
btw lib.mk can't handle relative paths yet. The problems you are seeing are related to that as well. This relative path issue should be fixed in lib.mk and not in individual tests.
Quoted 18 lines
/usr/bin/ld: cannot open output file/home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:141:/home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test] Error 1Signed-off-by Xiaoyao Li <[email protected]>--- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/kvm/Makefile +0
-0
tools/testing/selftests/kvm/Makefile LDFLAGS += -pthread $(no-pie-option) $(pgste-option) · line 69
Quoted 4 lines
tools/testing/selftests/kvm/Makefile +1
-0@@ -66,6 +66,7 @@ LDFLAGS += -pthread $(no-pie-option) $(pgste-option) # After inclusion, $(OUTPUT) is defined and # $(TEST_GEN_PROGS) starts with $(OUTPUT)/ include ../lib.mk +x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
lib.mk would have created the directory.
thanks,
-- Shuah
Re: [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified
Quoted 9 lines · shuah
Quoted 5 lines · Xiaoyao Li
When build kvm selftests to an specified directory with
make OUTPUT=~/kvm-selftests
it encouters following error:
btw lib.mk can't handle relative paths yet. The problems you are seeing are related to that as well.
I tried with absolute path as well. It didn't work.
Quoted 3 lines
This relative
path issue should be fixed in lib.mk and not in individual tests.
OK. I'll try to fix it in lib.mk
Quoted 28 lines
Quoted 20 lines
/usr/bin/ld: cannot open output file/home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [../lib.mk:141:/home/lxy/kvm-selftests/x86_64/cr4_cpuid_sync_test] Error 1Signed-off-by Xiaoyao Li <[email protected]>---
tools/testing/selftests/kvm/Makefile| 1 +1 file changed, 1 insertion(+)tools/testing/selftests/kvm/Makefile +0
-0@@ -66,6 +66,7 @@ LDFLAGS += -pthread $(no-pie-option) $(pgste-option) # After inclusion, $(OUTPUT) is defined and # $(TEST_GEN_PROGS) starts with $(OUTPUT)/Quoted 2 lines
include
../lib.mk
+x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))lib.mk would have created the directory.
thanks,
-- Shuah
PATCH 2/2 selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
In reply to Xiaoyao LiWhen build kvm selftests in tools/testing/selftests directory with
make O=~/kselftests TARGETS=kvm
it fails building some kvm test binaries due to lack of header files, e.g.,
x86_64/vmx_set_nested_state_test.c: In function ‘set_default_vmx_state’:x86_64/vmx_set_nested_state_test.c:85:7: error: ‘struct kvm_nested_state’ has no member named ‘hdr’
state->hdr.vmx.vmxon_pa = 0x1000;
kvm's Makefile unconditionally thinks kernel headers are installed in the "kernel-src/usr" with "INSTALL_HDR_PATH = $(top_srcdir)/usr". However, with "O" is specified, it also takes effect on "make headers_install", that causes no header files generated in "kernel-src/usr".
Export INSTALL_HDR_PATH when "O" is specified, so that kvm get the right kernel headers by checking if INSTALL_HDR_PATH is defined.
--- tools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/Makefile +5 -1
@@ -116,6 +116,10 @@ ARCH ?= $(SUBARCH) export KSFT_KHDR_INSTALL_DONE := 1 export BUILD +ifneq (1,$(DEFAULT_INSTALL_HDR_PATH)) +export INSTALL_HDR_PATH := $(BUILD)/usr +endif + # build and run gpio when output directory is the src dir. # gpio has dependency on tools/gpio and builds tools/gpio # objects in the src directory in all cases making the src
@@ -148,7 +152,7 @@ khdr: ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install else - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \ + $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(INSTALL_HDR_PATH) \ ARCH=$(ARCH) -C $(top_srcdir) headers_install endif
tools/testing/selftests/kvm/Makefile +1 -1
@@ -44,7 +44,7 @@ TEST_GEN_PROGS_s390x += kvm_create_max_vcpus TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) LIBKVM += $(LIBKVM_$(UNAME_M)) -INSTALL_HDR_PATH = $(top_srcdir)/usr +INSTALL_HDR_PATH ?= $(top_srcdir)/usr LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
Signature · 1 line
2.20.1
Quoted 6 lines · Xiaoyao Li
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=~/mydir TARGETS=kvm" intools/testing/selftests, nor
"make OUTPUT=~/mydir" intools/testing/selftests/kvmwork.This series aims to make both work.
Quoted 8 lines
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specified
selftests: exportINSTALL_HDR_PATHif using "O" to specify output dirtools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-)
Queued, thanks.
Paolo
shuah
maintainerQuoted 11 lines · Paolo Bonzini
Quoted 10 lines · Xiaoyao Li
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=~/mydir TARGETS=kvm" intools/testing/selftests, nor
"make OUTPUT=~/mydir" intools/testing/selftests/kvmwork.This series aims to make both work.
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specified
selftests: exportINSTALL_HDR_PATHif using "O" to specify output dir
Quoted 10 lines
Quoted 4 lines
tools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-)Queued, thanks.
Paolo
Sorry for the delay. I would like to see these two to go through kselftest tree. These involve frame work changes and will cause problems if they aren't integrated in kselftest next branch.
thanks,
-- Shuah
shuah
maintainerQuoted 9 lines · Paolo Bonzini
Quoted 8 lines · Xiaoyao Li
I attempted to build KVM selftests on a specified dir, unfortunately
neither "make O=~/mydir TARGETS=kvm" intools/testing/selftests, nor
"make OUTPUT=~/mydir" intools/testing/selftests/kvmwork.This series aims to make both work.
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specified
This definitely isn't thr right fix for this issue.
Quoted 1 line
Quoted 1 line
selftests: export
INSTALL_HDR_PATHif using "O" to specify output dir
Might be okay, but hard to find problems with the limited testing done just on the kvm test.
Quoted 11 lines
Quoted 5 lines
tools/testing/selftests/Makefile | 6 +++++- tools/testing/selftests/kvm/Makefile | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-)Queued, thanks.
Paolo
Can you please drop these for your queue. I would like to make sure they work with other patches queued in kselftest next and would like these go through kselftest tree.
It will be easier to find regressions when tested with other patches to framework as opposed to limited testing on just the kvm test.
thanks,
-- Shuah
Paolo Bonzini
maintainerQuoted 29 lines · shuah
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Xiaoyao Li
I attempted to build KVM selftests on a specified dir, unfortunately neither "make O=~/mydir TARGETS=kvm" in
tools/testing/selftests, nor "make OUTPUT=~/mydir" intools/testing/selftests/kvmwork.This series aims to make both work.
Xiaoyao Li (2):
kvm: selftests: Fix no directory error when OUTPUT specifiedThis definitely isn't thr right fix for this issue.
Quoted 1 line
Quoted 1 line
selftests: export
INSTALL_HDR_PATHif using "O" to specify output dirMight be okay, but hard to find problems with the limited testing done just on the kvm test.
Quoted 11 lines
Quoted 5 lines
tools/testing/selftests/Makefile | 6 +++++-
tools/testing/selftests/kvm/Makefile| 3 ++-2 files changed, 7 insertions(+), 2 deletions(-)Queued, thanks.
Paolo
Quoted 6 lines
Can you please drop these for your queue. I would like to make sure they work with other patches queued in kselftest next and would like these go through kselftest tree.
It will be easier to find regressions when tested with other patches to framework as opposed to limited testing on just the kvm test.
Sure, thanks.
Paolo