linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix errors when try to build kvm selftests on
@ 2020-03-15  9:34 Xiaoyao Li
  2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Xiaoyao Li @ 2020-03-15  9:34 UTC (permalink / raw)
  To: Shuah Khan, Paolo Bonzini, linux-kselftest, linux-kernel, kvm; +Cc: 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" 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(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified
  2020-03-15  9:34 [PATCH 0/2] Fix errors when try to build kvm selftests on Xiaoyao Li
@ 2020-03-15  9:34 ` Xiaoyao Li
  2020-03-23 15:40   ` shuah
  2020-03-15  9:34 ` [PATCH 2/2] selftests: export INSTALL_HDR_PATH if using "O" to specify output dir Xiaoyao Li
  2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
  2 siblings, 1 reply; 9+ messages in thread
From: Xiaoyao Li @ 2020-03-15  9:34 UTC (permalink / raw)
  To: Shuah Khan, Paolo Bonzini, linux-kselftest, linux-kernel, kvm; +Cc: Xiaoyao Li

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

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 tools/testing/selftests/kvm/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index d91c53b726e6..86797e0242d4 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -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))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
  2020-03-15  9:34 [PATCH 0/2] Fix errors when try to build kvm selftests on Xiaoyao Li
  2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
@ 2020-03-15  9:34 ` Xiaoyao Li
  2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
  2 siblings, 0 replies; 9+ messages in thread
From: Xiaoyao Li @ 2020-03-15  9:34 UTC (permalink / raw)
  To: Shuah Khan, Paolo Bonzini, linux-kselftest, linux-kernel, kvm; +Cc: Xiaoyao Li

When 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.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 tools/testing/selftests/Makefile     | 6 +++++-
 tools/testing/selftests/kvm/Makefile | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 6ec503912bea..5fd72d955e24 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -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
 
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 86797e0242d4..c14d23c978d5 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -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
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix errors when try to build kvm selftests on
  2020-03-15  9:34 [PATCH 0/2] Fix errors when try to build kvm selftests on Xiaoyao Li
  2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
  2020-03-15  9:34 ` [PATCH 2/2] selftests: export INSTALL_HDR_PATH if using "O" to specify output dir Xiaoyao Li
@ 2020-03-18 13:13 ` Paolo Bonzini
  2020-03-23 15:33   ` shuah
  2020-03-23 15:44   ` shuah
  2 siblings, 2 replies; 9+ messages in thread
From: Paolo Bonzini @ 2020-03-18 13:13 UTC (permalink / raw)
  To: Xiaoyao Li, Shuah Khan, linux-kselftest, linux-kernel, kvm

On 15/03/20 10:34, Xiaoyao Li wrote:
> 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(-)
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix errors when try to build kvm selftests on
  2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
@ 2020-03-23 15:33   ` shuah
  2020-03-23 15:44   ` shuah
  1 sibling, 0 replies; 9+ messages in thread
From: shuah @ 2020-03-23 15:33 UTC (permalink / raw)
  To: Paolo Bonzini, Xiaoyao Li, linux-kselftest, linux-kernel, kvm, shuah

On 3/18/20 7:13 AM, Paolo Bonzini wrote:
> On 15/03/20 10:34, Xiaoyao Li wrote:
>> 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(-)
>>
> 
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified
  2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
@ 2020-03-23 15:40   ` shuah
  2020-03-24  1:51     ` Xiaoyao Li
  0 siblings, 1 reply; 9+ messages in thread
From: shuah @ 2020-03-23 15:40 UTC (permalink / raw)
  To: Xiaoyao Li, Paolo Bonzini, linux-kselftest, linux-kernel, kvm; +Cc: shuah

On 3/15/20 3:34 AM, Xiaoyao Li wrote:
> 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.

> 
> /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
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>   tools/testing/selftests/kvm/Makefile | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index d91c53b726e6..86797e0242d4 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix errors when try to build kvm selftests on
  2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
  2020-03-23 15:33   ` shuah
@ 2020-03-23 15:44   ` shuah
  2020-03-23 19:42     ` Paolo Bonzini
  1 sibling, 1 reply; 9+ messages in thread
From: shuah @ 2020-03-23 15:44 UTC (permalink / raw)
  To: Paolo Bonzini, Xiaoyao Li, linux-kselftest, linux-kernel, kvm, shuah

On 3/18/20 7:13 AM, Paolo Bonzini wrote:
> On 15/03/20 10:34, Xiaoyao Li wrote:
>> 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

This definitely isn't thr right fix for this issue.

>>    selftests: export INSTALL_HDR_PATH if using "O" to specify output dir

Might be okay, but hard to find problems with the limited testing
done just on the kvm test.

>>
>>   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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix errors when try to build kvm selftests on
  2020-03-23 15:44   ` shuah
@ 2020-03-23 19:42     ` Paolo Bonzini
  0 siblings, 0 replies; 9+ messages in thread
From: Paolo Bonzini @ 2020-03-23 19:42 UTC (permalink / raw)
  To: shuah, Xiaoyao Li, linux-kselftest, linux-kernel, kvm

On 23/03/20 16:44, shuah wrote:
> On 3/18/20 7:13 AM, Paolo Bonzini wrote:
>> On 15/03/20 10:34, Xiaoyao Li wrote:
>>> 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
> 
> This definitely isn't thr right fix for this issue.
> 
>>>    selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
> 
> Might be okay, but hard to find problems with the limited testing
> done just on the kvm test.
> 
>>>
>>>   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.

Sure, thanks.

Paolo


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified
  2020-03-23 15:40   ` shuah
@ 2020-03-24  1:51     ` Xiaoyao Li
  0 siblings, 0 replies; 9+ messages in thread
From: Xiaoyao Li @ 2020-03-24  1:51 UTC (permalink / raw)
  To: shuah, Paolo Bonzini, linux-kselftest, linux-kernel, kvm

On 3/23/2020 11:40 PM, shuah wrote:
> On 3/15/20 3:34 AM, Xiaoyao Li wrote:
>> 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.

> 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

>>
>> /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
>>
>> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
>> ---
>>   tools/testing/selftests/kvm/Makefile | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/tools/testing/selftests/kvm/Makefile 
>> b/tools/testing/selftests/kvm/Makefile
>> index d91c53b726e6..86797e0242d4 100644
>> --- a/tools/testing/selftests/kvm/Makefile
>> +++ b/tools/testing/selftests/kvm/Makefile
>> @@ -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
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-24  1:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15  9:34 [PATCH 0/2] Fix errors when try to build kvm selftests on Xiaoyao Li
2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
2020-03-23 15:40   ` shuah
2020-03-24  1:51     ` Xiaoyao Li
2020-03-15  9:34 ` [PATCH 2/2] selftests: export INSTALL_HDR_PATH if using "O" to specify output dir Xiaoyao Li
2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
2020-03-23 15:33   ` shuah
2020-03-23 15:44   ` shuah
2020-03-23 19:42     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).