public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] test: Kernel binary can now be passed via the KERNEL environmental variable
@ 2024-09-27 17:17 Stefano Brivio
  2024-09-29  6:21 ` David Gibson
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Brivio @ 2024-09-27 17:17 UTC (permalink / raw)
  To: passt-dev

This is quite useful at least for myself as I'm usually running tests
using a guest kernel that's not the same as the one on the host.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 test/lib/setup | 8 ++++----
 test/lib/term  | 2 +-
 test/run       | 3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/lib/setup b/test/lib/setup
index d764138..5338393 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -58,7 +58,7 @@ setup_passt() {
 	context_run_bg qemu 'qemu-system-'"${QEMU_ARCH}"		   \
 		' -machine accel=kvm'                                      \
 		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
-		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
+		' -kernel '"${KERNEL}"					   \
 		' -initrd '${INITRAMFS}' -nographic -serial stdio'	   \
 		' -nodefaults'						   \
 		' -append "console=ttyS0 mitigations=off apparmor=0" '	   \
@@ -159,7 +159,7 @@ setup_passt_in_ns() {
 		' -machine accel=kvm'                                      \
 		' -M accel=kvm:tcg'                                        \
 		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
-		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
+		' -kernel '"${KERNEL}"					   \
 		' -initrd '${INITRAMFS}' -nographic -serial stdio'	   \
 		' -nodefaults'						   \
 		' -append "console=ttyS0 mitigations=off apparmor=0" '	   \
@@ -230,7 +230,7 @@ setup_two_guests() {
 	context_run_bg qemu_1 'qemu-system-'"${QEMU_ARCH}"		     \
 		' -M accel=kvm:tcg'                                          \
 		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
-		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
+		' -kernel '"${KERNEL}"					     \
 		' -initrd '${INITRAMFS}' -nographic -serial stdio'	     \
 		' -nodefaults'						     \
 		' -append "console=ttyS0 mitigations=off apparmor=0" '	     \
@@ -243,7 +243,7 @@ setup_two_guests() {
 	context_run_bg qemu_2 'qemu-system-'"${QEMU_ARCH}"		     \
 		' -M accel=kvm:tcg'                                          \
 		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
-		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
+		' -kernel '"${KERNEL}"					     \
 		' -initrd '${INITRAMFS}' -nographic -serial stdio'	     \
 		' -nodefaults'						     \
 		' -append "console=ttyS0 mitigations=off apparmor=0" '	     \
diff --git a/test/lib/term b/test/lib/term
index 3834092..0fa0936 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -664,7 +664,7 @@ pause_continue() {
 
 # run_term() - Start tmux session, running entry point, with recording if needed
 run_term() {
-	TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG"
+	TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG -eKERNEL=$KERNEL"
 
 	if [ ${CI} -eq 1 ]; then
 		printf '\e[8;50;240t'
diff --git a/test/run b/test/run
index cd6d707..547a729 100755
--- a/test/run
+++ b/test/run
@@ -38,6 +38,9 @@ TRACE=${TRACE:-0}
 # If set, tell passt and pasta to take packet captures
 PCAP=${PCAP:-0}
 
+# Custom kernel to boot guests with, if given
+KERNEL=${KERNEL:-"/boot/vmlinuz-$(uname -r)"}
+
 COMMIT="$(git log --oneline --no-decorate -1)"
 
 . lib/util
-- 
@@ -38,6 +38,9 @@ TRACE=${TRACE:-0}
 # If set, tell passt and pasta to take packet captures
 PCAP=${PCAP:-0}
 
+# Custom kernel to boot guests with, if given
+KERNEL=${KERNEL:-"/boot/vmlinuz-$(uname -r)"}
+
 COMMIT="$(git log --oneline --no-decorate -1)"
 
 . lib/util
-- 
2.43.0


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

* Re: [PATCH] test: Kernel binary can now be passed via the KERNEL environmental variable
  2024-09-27 17:17 [PATCH] test: Kernel binary can now be passed via the KERNEL environmental variable Stefano Brivio
@ 2024-09-29  6:21 ` David Gibson
  2024-09-30  8:39   ` Stefano Brivio
  0 siblings, 1 reply; 3+ messages in thread
From: David Gibson @ 2024-09-29  6:21 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 3904 bytes --]

On Fri, Sep 27, 2024 at 07:17:14PM +0200, Stefano Brivio wrote:
> This is quite useful at least for myself as I'm usually running tests
> using a guest kernel that's not the same as the one on the host.

Hm.  I don't love doing this without also altering the mbuto.img
creation to use the same kernel.

But.. it's hardly the only mucky thing about the makefiles so,

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>  test/lib/setup | 8 ++++----
>  test/lib/term  | 2 +-
>  test/run       | 3 +++
>  3 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/test/lib/setup b/test/lib/setup
> index d764138..5338393 100755
> --- a/test/lib/setup
> +++ b/test/lib/setup
> @@ -58,7 +58,7 @@ setup_passt() {
>  	context_run_bg qemu 'qemu-system-'"${QEMU_ARCH}"		   \
>  		' -machine accel=kvm'                                      \
>  		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
> -		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
> +		' -kernel '"${KERNEL}"					   \
>  		' -initrd '${INITRAMFS}' -nographic -serial stdio'	   \
>  		' -nodefaults'						   \
>  		' -append "console=ttyS0 mitigations=off apparmor=0" '	   \
> @@ -159,7 +159,7 @@ setup_passt_in_ns() {
>  		' -machine accel=kvm'                                      \
>  		' -M accel=kvm:tcg'                                        \
>  		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
> -		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
> +		' -kernel '"${KERNEL}"					   \
>  		' -initrd '${INITRAMFS}' -nographic -serial stdio'	   \
>  		' -nodefaults'						   \
>  		' -append "console=ttyS0 mitigations=off apparmor=0" '	   \
> @@ -230,7 +230,7 @@ setup_two_guests() {
>  	context_run_bg qemu_1 'qemu-system-'"${QEMU_ARCH}"		     \
>  		' -M accel=kvm:tcg'                                          \
>  		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
> -		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
> +		' -kernel '"${KERNEL}"					     \
>  		' -initrd '${INITRAMFS}' -nographic -serial stdio'	     \
>  		' -nodefaults'						     \
>  		' -append "console=ttyS0 mitigations=off apparmor=0" '	     \
> @@ -243,7 +243,7 @@ setup_two_guests() {
>  	context_run_bg qemu_2 'qemu-system-'"${QEMU_ARCH}"		     \
>  		' -M accel=kvm:tcg'                                          \
>  		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
> -		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
> +		' -kernel '"${KERNEL}"					     \
>  		' -initrd '${INITRAMFS}' -nographic -serial stdio'	     \
>  		' -nodefaults'						     \
>  		' -append "console=ttyS0 mitigations=off apparmor=0" '	     \
> diff --git a/test/lib/term b/test/lib/term
> index 3834092..0fa0936 100755
> --- a/test/lib/term
> +++ b/test/lib/term
> @@ -664,7 +664,7 @@ pause_continue() {
>  
>  # run_term() - Start tmux session, running entry point, with recording if needed
>  run_term() {
> -	TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG"
> +	TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG -eKERNEL=$KERNEL"
>  
>  	if [ ${CI} -eq 1 ]; then
>  		printf '\e[8;50;240t'
> diff --git a/test/run b/test/run
> index cd6d707..547a729 100755
> --- a/test/run
> +++ b/test/run
> @@ -38,6 +38,9 @@ TRACE=${TRACE:-0}
>  # If set, tell passt and pasta to take packet captures
>  PCAP=${PCAP:-0}
>  
> +# Custom kernel to boot guests with, if given
> +KERNEL=${KERNEL:-"/boot/vmlinuz-$(uname -r)"}
> +
>  COMMIT="$(git log --oneline --no-decorate -1)"
>  
>  . lib/util

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] test: Kernel binary can now be passed via the KERNEL environmental variable
  2024-09-29  6:21 ` David Gibson
@ 2024-09-30  8:39   ` Stefano Brivio
  0 siblings, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2024-09-30  8:39 UTC (permalink / raw)
  To: David Gibson; +Cc: passt-dev

On Sun, 29 Sep 2024 16:21:30 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Fri, Sep 27, 2024 at 07:17:14PM +0200, Stefano Brivio wrote:
> > This is quite useful at least for myself as I'm usually running tests
> > using a guest kernel that's not the same as the one on the host.  
> 
> Hm.  I don't love doing this without also altering the mbuto.img
> creation to use the same kernel.

I rarely use the Makefile under test/ because I'm running these tests
mostly as ./ci, but yes, I was thinking about that as well.

On the other hand, mbuto needs a kernel version to figure out where the
kernel modules are, whereas the tests need a kernel binary, and I
didn't really have good ideas to take both into account without
introducing two variables in the Makefile which looks a bit clunky.

-- 
Stefano


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

end of thread, other threads:[~2024-09-30  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-27 17:17 [PATCH] test: Kernel binary can now be passed via the KERNEL environmental variable Stefano Brivio
2024-09-29  6:21 ` David Gibson
2024-09-30  8:39   ` Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).