public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/5] Test fixes, batch 3
@ 2022-06-23  2:22 David Gibson
  2022-06-23  2:22 ` [PATCH 1/5] tests: qemu-system-ppc64le isn't a thing David Gibson
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

Here's another batch of fixes to get more passt/pasta tests running on
my system, this time focused on the distro test cases.  A number of
those tests now run on my Fedora 36 host.  Unfortunately they still
fail on the Fedora 30, aarch64 test for reasons I haven't figured out
(one of the yum downloads times out with passt but not -net user).

This series is based on my earlier series adding the new "lineread"
subsystem.

David Gibson (5):
  tests: qemu-system-ppc64le isn't a thing
  Invoke specific qemu-system-* binaries
  tests: Cache downloaded guest images
  Handle the case of a DNS server on localhost
  tests: Try multiple paths for aarch64 EDK2 bios image

 conf.c               |  16 +++++++
 passt.1              |   6 +--
 test/.gitignore      |   1 +
 test/demo/passt      |   2 +-
 test/distro/debian   |  60 +++++++++++---------------
 test/distro/fedora   | 100 +++++++++++++++++++------------------------
 test/distro/opensuse |  23 +++++-----
 test/distro/ubuntu   |  25 +++++------
 test/lib/setup       |  15 +++++--
 test/lib/test        |  12 ++++++
 test/run             |   4 ++
 11 files changed, 140 insertions(+), 124 deletions(-)

-- 
2.36.1


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

* [PATCH 1/5] tests: qemu-system-ppc64le isn't a thing
  2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
@ 2022-06-23  2:22 ` David Gibson
  2022-06-23  2:22 ` [PATCH 2/5] Invoke specific qemu-system-* binaries David Gibson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

Several tests run pp64le guests using "qemu-system-ppc64le".  But, at the
system level there's no difference between ppc64 and ppc64le - it's the
same hardware, just placed into different endian modes by OS early boot
code.  Reflecting that, qemu only supplies a single "qemu-system-ppc64".

Some distros alias qemu-system-ppc64le to qemu-system-ppc64 (Debian does),
but it's best not to count on this (Fedora doesn't, for example).

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/distro/debian | 8 ++++----
 test/distro/ubuntu | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/distro/debian b/test/distro/debian
index efbd057..0ed541a 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-aarch64 qemu-system-ppc64le
+htools	wget virt-edit guestfish head sed cat kill qemu-system-aarch64 qemu-system-ppc64
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -168,7 +168,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -252,7 +252,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
@@ -318,7 +318,7 @@ host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.serv
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 448409a..50ed727 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-ppc64le qemu-system-s390x
+htools	wget virt-edit guestfish head sed cat kill qemu-system-ppc64 qemu-system-s390x
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -118,7 +118,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
-- 
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-ppc64le qemu-system-s390x
+htools	wget virt-edit guestfish head sed cat kill qemu-system-ppc64 qemu-system-s390x
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -118,7 +118,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-ppc64le -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-ppc64 -m 2048 -smp 2 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
-- 
2.36.1


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

* [PATCH 2/5] Invoke specific qemu-system-* binaries
  2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
  2022-06-23  2:22 ` [PATCH 1/5] tests: qemu-system-ppc64le isn't a thing David Gibson
@ 2022-06-23  2:22 ` David Gibson
  2022-06-28  5:25   ` David Gibson
  2022-06-23  2:22 ` [PATCH 3/5] tests: Cache downloaded guest images David Gibson
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

A lot of tests and examples invoke qemu with the command "kvm".  However,
as far as I can tell, "kvm" being aliased to the appropriate qemu system
binary is Debian specific.  The binary names from qemu upstream -
qemu-system-$ARCH - also aren't universal, but they are more common (they
should be good for both Debian and Fedora at least).

In order to still get KVM acceleration when available, we use the option
"-M accel=kvm:tcg" to tell qemu to try using either KVM or TCG in that
order

A number of the places we invoked "kvm" are expecting specifically an x86
guest, and so it's also safer to explicitly invoke qemu-system-x86_64.

Some others appear to be independent of the target arch (just wanting the
same arch as the host to allow KVM acceleration).  Although I suspect there
may be more subtle x86 specific options in the qemu command lines, attempt
to preserve arch independence by using $(uname -m).

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 passt.1              |  6 +++---
 test/demo/passt      |  2 +-
 test/distro/debian   | 12 ++++++------
 test/distro/fedora   | 22 +++++++++++-----------
 test/distro/opensuse | 10 +++++-----
 test/distro/ubuntu   |  8 ++++----
 test/lib/setup       | 15 +++++++++++----
 7 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/passt.1 b/passt.1
index 3dccc63..c7c43be 100644
--- a/passt.1
+++ b/passt.1
@@ -616,16 +616,16 @@ NDP/DHCPv6:
 UNIX domain socket bound at /tmp/passt_1.socket
 
 You can now start qrap:
-    ./qrap 5 kvm ... -net socket,fd=5 -net nic,model=virtio
+    ./qrap 5 qemu-system-x86_64 ... -net socket,fd=5 -net nic,model=virtio
 or directly qemu, patched with:
     qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.patch
 as follows:
-    kvm ... -net socket,connect=/tmp/passt_1.socket -net nic,model=virtio
+    qemu-system-x86_64 ... -net socket,connect=/tmp/passt_1.socket -net nic,model=virtio
 
 .fi
 .BR "	[From another terminal]"
 .nf
-$ ./qrap 5 kvm test.qcow2 -m 1024 -display none -nodefaults -nographic -net socket,fd=5 -net nic,model=virtio
+$ ./qrap 5 qemu-system-x86_64 test.qcow2 -m 1024 -display none -nodefaults -nographic -net socket,fd=5 -net nic,model=virtio
 Connected to /tmp/passt_1.socket
 
 .fi
diff --git a/test/demo/passt b/test/demo/passt
index ee4e7c2..0ece04f 100644
--- a/test/demo/passt
+++ b/test/demo/passt
@@ -103,7 +103,7 @@ nl
 say	  back-end to passt's UNIX domain socket.
 sleep	2
 hout	VMLINUZ echo "/boot/vmlinuz-$(uname -r)"
-guest	../passt/qrap 5 kvm -m 4096 -cpu host -smp 4 -kernel __VMLINUZ__ -initrd passt.img -nographic -serial stdio -nodefaults -append "console=ttyS0 virtio-net.napi_tx=1" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384 -netdev socket,fd=5,id=hostnet0
+guest	../passt/qrap 5 qemu-system-x86_64 -enable-kvm -m 4096 -cpu host -smp 4 -kernel __VMLINUZ__ -initrd passt.img -nographic -serial stdio -nodefaults -append "console=ttyS0 virtio-net.napi_tx=1" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384 -netdev socket,fd=5,id=hostnet0
 sleep	10
 
 nl
diff --git a/test/distro/debian b/test/distro/debian
index 0ed541a..ce3b9e7 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-aarch64 qemu-system-ppc64
+htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -54,7 +54,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -81,7 +81,7 @@ host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.serv
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -105,7 +105,7 @@ host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.serv
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -193,7 +193,7 @@ host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.serv
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
@@ -275,7 +275,7 @@ host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.serv
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
diff --git a/test/distro/fedora b/test/distro/fedora
index c82d973..2a8e3e9 100644
--- a/test/distro/fedora
+++ b/test/distro/fedora
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill
+htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -75,7 +75,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -105,7 +105,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -132,7 +132,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -187,7 +187,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -242,7 +242,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -297,7 +297,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -352,7 +352,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -407,7 +407,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -462,7 +462,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -517,7 +517,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
diff --git a/test/distro/opensuse b/test/distro/opensuse
index 2b49a5b..132474b 100644
--- a/test/distro/opensuse
+++ b/test/distro/opensuse
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill kvm qemu-system-aarch64 xzcat tr
+htools	wget virt-edit guestfish head sed cat kill kvm qemu-system-x86_64 qemu-system-aarch64 xzcat tr
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -51,7 +51,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/je
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 host	ip link set eth0 up
 sleep	2
@@ -79,7 +79,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/je
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 host	ip link set eth0 up
 sleep	2
@@ -104,7 +104,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/je
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 # Multiple prompt logins might come up here
 sleep	10
 host	PS1='$ '
@@ -186,7 +186,7 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/serial-getty(a).servi
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 host	ip link set ens2 up
 sleep	2
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 50ed727..20b861a 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: AGPL-3.0-or-later
+<# SPDX-License-Identifier: AGPL-3.0-or-later
 #
 # PASST - Plug A Simple Socket Transport
 #  for qemu/UNIX domain socket mode
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-ppc64 qemu-system-s390x
+htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -55,7 +55,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -88,7 +88,7 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-init.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-log-shutdown.conf
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 kvm -M pc -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
+host	./qrap 5 qemu-system-x86_64 -M pc,accel=kvm:tcg -m 1024 -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none -drive file=__IMG__,if=virtio -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
diff --git a/test/lib/setup b/test/lib/setup
index e57d97c..0b6d915 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -58,7 +58,8 @@ setup_passt() {
 	pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid"
 	sleep 5
 
-	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
+		'-m '${VMEM}' -cpu host -smp '${VCPUS}                     \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
 		' -initrd mbuto.img -nographic -serial stdio'		   \
 		' -nodefaults'						   \
@@ -170,7 +171,9 @@ setup_passt_in_ns() {
 	fi
 	sleep 5
 
-	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                        \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
 		' -initrd mbuto.img -nographic -serial stdio'		   \
 		' -nodefaults'						   \
@@ -259,7 +262,9 @@ setup_two_guests() {
 	pane_run GUEST_2 'cp mbuto.img mbuto_2.img'
 	pane_status GUEST_2
 
-	pane_run GUEST_1 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST_1 './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                          \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
 		' -initrd mbuto.img -nographic -serial stdio'		     \
 		' -nodefaults'						     \
@@ -267,7 +272,9 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"
-	pane_run GUEST_2 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST_2 './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                          \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
 		' -initrd mbuto_2.img -nographic -serial stdio'		     \
 		' -nodefaults'						     \
-- 
@@ -58,7 +58,8 @@ setup_passt() {
 	pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid"
 	sleep 5
 
-	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
+		'-m '${VMEM}' -cpu host -smp '${VCPUS}                     \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
 		' -initrd mbuto.img -nographic -serial stdio'		   \
 		' -nodefaults'						   \
@@ -170,7 +171,9 @@ setup_passt_in_ns() {
 	fi
 	sleep 5
 
-	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                        \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
 		' -initrd mbuto.img -nographic -serial stdio'		   \
 		' -nodefaults'						   \
@@ -259,7 +262,9 @@ setup_two_guests() {
 	pane_run GUEST_2 'cp mbuto.img mbuto_2.img'
 	pane_status GUEST_2
 
-	pane_run GUEST_1 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST_1 './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                          \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
 		' -initrd mbuto.img -nographic -serial stdio'		     \
 		' -nodefaults'						     \
@@ -267,7 +272,9 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"
-	pane_run GUEST_2 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
+	pane_run GUEST_2 './qrap 5 qemu-system-$(uname -m)'                  \
+		' -M accel=kvm:tcg'                                          \
+		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
 		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
 		' -initrd mbuto_2.img -nographic -serial stdio'		     \
 		' -nodefaults'						     \
-- 
2.36.1


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

* [PATCH 3/5] tests: Cache downloaded guest images
  2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
  2022-06-23  2:22 ` [PATCH 1/5] tests: qemu-system-ppc64le isn't a thing David Gibson
  2022-06-23  2:22 ` [PATCH 2/5] Invoke specific qemu-system-* binaries David Gibson
@ 2022-06-23  2:22 ` David Gibson
  2022-06-23  2:22 ` [PATCH 4/5] Handle the case of a DNS server on localhost David Gibson
  2022-06-23  2:22 ` [PATCH 5/5] tests: Try multiple paths for aarch64 EDK2 bios image David Gibson
  4 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

The "distro" tests download a lot of distro guest images.  This is done
from scratch, from the primary upstream site, on every single run.  For
those of us network-distant from those primary sites, this gets *very*
tedious.

Add an extra testing command "testimg" which will make a scratch image,
while caching the download of the original unmodified image.  The approach
isn't entirely bulletproof, but it should be good enough for our purposes.

In addition to caching the raw downloaded images, this also makes the
temporary qcow2 images use the raw image as a backing file, which means
less space consumed in /tmp if the temporary image isn't cleaned up.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/.gitignore      |  1 +
 test/distro/debian   | 35 ++++++++++-----------------
 test/distro/fedora   | 56 +++++++++++++++-----------------------------
 test/distro/opensuse | 12 ++++------
 test/distro/ubuntu   | 17 +++++---------
 test/lib/test        | 12 ++++++++++
 test/run             |  4 ++++
 7 files changed, 59 insertions(+), 78 deletions(-)

diff --git a/test/.gitignore b/test/.gitignore
index edb2221..3ca2ae2 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,2 +1,3 @@
 perf.js
 test_logs/
+test_imgs/
diff --git a/test/distro/debian b/test/distro/debian
index ce3b9e7..6c25f22 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64
+htools	virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -44,8 +44,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
 
 test	Debian GNU/Linux 8 (jessie), amd64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/OpenStack/archive/8.11.0/debian-8.11.0-openstack-amd64.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/OpenStack/archive/8.11.0/debian-8.11.0-openstack-amd64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-config
@@ -75,8 +74,7 @@ hout	PID cat __PIDFILE__
 
 test	Debian GNU/Linux 9 (stretch, oldoldstable), amd64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/stretch/daily/20200210-166/debian-9-nocloud-amd64-daily-20200210-166.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/stretch/daily/20200210-166/debian-9-nocloud-amd64-daily-20200210-166.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -99,8 +97,7 @@ sleep	1
 
 test	Debian GNU/Linux 10 (buster, oldstable), amd64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-nocloud-amd64.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/buster/latest/debian-10-nocloud-amd64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -123,8 +120,7 @@ sleep	1
 
 test	Debian GNU/Linux 10 (buster, oldstable), aarch64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-arm64.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-arm64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -154,8 +150,7 @@ sleep	1
 
 test	Debian GNU/Linux 10 (buster, oldstable), ppc64le
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-ppc64el.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-ppc64el.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
@@ -187,8 +182,7 @@ hostb	reset
 
 test	Debian GNU/Linux 11 (bullseye, stable), amd64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -209,8 +203,7 @@ sleep	1
 
 test	Debian GNU/Linux 11 (bullseye, stable), aarch64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm64.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -238,8 +231,7 @@ sleep	1
 
 test	Debian GNU/Linux 11 (bullseye, stable), ppc64le
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-ppc64el.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-ppc64el.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
@@ -269,8 +261,7 @@ hostb	reset
 
 test	Debian GNU/Linux sid (experimental), amd64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-amd64-daily.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-amd64-daily.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -291,8 +282,7 @@ sleep	1
 
 test	Debian GNU/Linux sid (experimental), aarch64
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-arm64-daily.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-arm64-daily.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
@@ -312,8 +302,7 @@ sleep	1
 
 test	Debian GNU/Linux sid (experimental), ppc64le
 
-temp	IMG
-host	wget https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-ppc64el-daily.qcow2 -O __IMG__
+tempimg	IMG https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-ppc64el-daily.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
diff --git a/test/distro/fedora b/test/distro/fedora
index 2a8e3e9..904c987 100644
--- a/test/distro/fedora
+++ b/test/distro/fedora
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64
+htools	virt-edit guestfish head sed cat kill qemu-system-x86_64
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -65,8 +65,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
 
 test	Fedora 26, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/CloudImages/x86_64/images/Fedora-Cloud-Base-26-1.5.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/CloudImages/x86_64/images/Fedora-Cloud-Base-26-1.5.x86_64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
@@ -95,8 +94,7 @@ hout	PID cat __PIDFILE__
 
 test	Fedora 27, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
@@ -122,8 +120,7 @@ sleep	1
 
 test	Fedora 28, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.qcow2
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /lib/systemd/system/serial-getty(a).service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
@@ -149,8 +146,7 @@ sleep	1
 
 test	Fedora 28, aarch64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Cloud/aarch64/images/Fedora-Cloud-Base-28-1.1.aarch64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Cloud/aarch64/images/Fedora-Cloud-Base-28-1.1.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -178,8 +174,7 @@ host	echo
 
 test	Fedora 29, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Cloud/x86_64/images/Fedora-Cloud-Base-29-1.2.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Cloud/x86_64/images/Fedora-Cloud-Base-29-1.2.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -204,8 +199,7 @@ sleep	1
 
 test	Fedora 29, aarch64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Cloud/aarch64/images/Fedora-Cloud-Base-29-1.2.aarch64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Cloud/aarch64/images/Fedora-Cloud-Base-29-1.2.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -233,8 +227,7 @@ host	echo
 
 test	Fedora 30, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Cloud/x86_64/images/Fedora-Cloud-Base-30-1.2.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Cloud/x86_64/images/Fedora-Cloud-Base-30-1.2.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -259,8 +252,7 @@ sleep	1
 
 test	Fedora 30, aarch64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Cloud/aarch64/images/Fedora-Cloud-Base-30-1.2.aarch64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Cloud/aarch64/images/Fedora-Cloud-Base-30-1.2.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -288,8 +280,7 @@ host	echo
 
 test	Fedora 31, x86_64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -314,8 +305,7 @@ sleep	1
 
 test	Fedora 31, aarch64
 
-temp	IMG
-host	wget http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Cloud/aarch64/images/Fedora-Cloud-Base-31-1.9.aarch64.qcow2 -O __IMG__
+tempimg	IMG http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Cloud/aarch64/images/Fedora-Cloud-Base-31-1.9.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -343,8 +333,7 @@ host	echo
 
 test	Fedora 32, x86_64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -369,8 +358,7 @@ sleep	1
 
 test	Fedora 32, aarch64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/aarch64/images/Fedora-Cloud-Base-32-1.6.aarch64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/aarch64/images/Fedora-Cloud-Base-32-1.6.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -398,8 +386,7 @@ host	echo
 
 test	Fedora 33, x86_64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -424,8 +411,7 @@ sleep	1
 
 test	Fedora 33, aarch64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/aarch64/images/Fedora-Cloud-Base-33-1.2.aarch64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/aarch64/images/Fedora-Cloud-Base-33-1.2.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -453,8 +439,7 @@ host	echo
 
 test	Fedora 34, x86_64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -479,8 +464,7 @@ sleep	1
 
 test	Fedora 34, aarch64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/aarch64/images/Fedora-Cloud-Base-34-1.2.aarch64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux//releases/34/Cloud/aarch64/images/Fedora-Cloud-Base-34-1.2.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -508,8 +492,7 @@ host	echo
 
 test	Fedora 35, x86_64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/x86_64/images/Fedora-Cloud-Base-35-1.2.x86_64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/x86_64/images/Fedora-Cloud-Base-35-1.2.x86_64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
@@ -534,8 +517,7 @@ sleep	1
 
 test	Fedora 35, aarch64
 
-temp	IMG
-host	wget https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/aarch64/images/Fedora-Cloud-Base-35-1.2.aarch64.qcow2 -O __IMG__
+tempimg	IMG https://download.fedoraproject.org/pub/fedora/linux/releases/35/Cloud/aarch64/images/Fedora-Cloud-Base-35-1.2.aarch64.qcow2
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
diff --git a/test/distro/opensuse b/test/distro/opensuse
index 132474b..617656d 100644
--- a/test/distro/opensuse
+++ b/test/distro/opensuse
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill kvm qemu-system-x86_64 qemu-system-aarch64 xzcat tr
+htools	virt-edit guestfish head sed cat kill kvm qemu-system-x86_64 qemu-system-aarch64 xzcat tr
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -44,8 +44,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
 
 test	OpenSUSE Leap 15.1
 
-temp	IMG
-host	wget https://download.opensuse.org/distribution/leap/15.1/jeos/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2 -O __IMG__
+tempimg	IMG https://download.opensuse.org/distribution/leap/15.1/jeos/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
@@ -73,7 +72,7 @@ hout	PID cat __PIDFILE__
 
 test	OpenSUSE Leap 15.2
 
-host	wget https://download.opensuse.org/distribution/leap/15.2/appliances/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2 -O __IMG__
+tempimg	IMG https://download.opensuse.org/distribution/leap/15.2/appliances/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
@@ -98,7 +97,7 @@ sleep	1
 
 test	OpenSUSE Leap 15.3
 
-host	wget https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 -O __IMG__
+tempimg	IMG https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
 host	virt-edit -a __IMG__ /etc/systemd/system/getty.target.wants/getty(a)tty1.service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 ttyS0 $TERM/g'
@@ -178,8 +177,7 @@ sleep	1
 
 test	OpenSUSE Tumbleweed
 
-temp	IMG
-host	wget https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2 -O __IMG__
+tempimg	IMG https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/systemd-journald.service
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/serial-getty(a).service
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 20b861a..c8c3970 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -12,7 +12,7 @@
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
 temp	PIDFILE
-htools	wget virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x
+htools	virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x
 
 # Quick pasta test: send message from init to ns, and from ns to init
 def	distro_quick_pasta_test
@@ -43,8 +43,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile | tr '\n' ' '; echo
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), amd64
 
-temp	IMG
-host	wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img -O __IMG__
+tempimg	IMG https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
 host	virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf
@@ -76,8 +75,7 @@ hout	PID cat __PIDFILE__
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), i386
 
-temp	IMG
-host	wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-i386-disk1.img -O __IMG__
+tempimg	IMG https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-i386-disk1.img
 host	virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf
@@ -106,8 +104,7 @@ sleep	1
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le
 
-temp	IMG
-host	wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-ppc64el-disk1.img -O __IMG__
+tempimg	IMG https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-ppc64el-disk1.img
 host	virt-edit -a __IMG__ /etc/init/hvc0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-final.conf
@@ -139,8 +136,7 @@ host	echo
 
 test	Ubuntu 16.04 LTS (Xenial Xerus), ppc64 (be)
 
-temp	IMG
-host	wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-powerpc-disk1.img -O __IMG__
+tempimg	IMG https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-powerpc-disk1.img
 host	virt-edit -a __IMG__ /lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/cloud-init.target.wants/cloud-final.service
@@ -169,8 +165,7 @@ host	echo
 
 
 test	Ubuntu 22.04 (Jammy Jellyfish), s390x
-temp	IMG
-host	wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-s390x.img -O __IMG__
+tempimg	IMG https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-s390x.img
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-config.service
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init.service
diff --git a/test/lib/test b/test/lib/test
index 09e8340..cfb2886 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -128,6 +128,18 @@ test_one_line() {
 		TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpfile}")"
 		TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")"
 		;;
+	"tempimg")
+		__varname="${__arg%% *}"
+		__url="${__arg#* }"
+		__tmpfile="$(mktemp)"
+		TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "${__tmpfile}")"
+		TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")"
+		__cachename="${IMGDIR}/$(basename ${__url})"
+		pane_run HOST wget -c -O "${__cachename}" "${__url}"
+		pane_status HOST || TEST_ONE_nok=1
+		pane_run HOST qemu-img create -f qcow2 -F qcow2 -b "${__cachename}" "${__tmpfile}"
+		pane_status HOST || TEST_ONE_nok=1
+		;;
 	"test")
 		[ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=1
 		[ ${TEST_ONE_nok} -eq 1 ] && status_test_fail
diff --git a/test/run b/test/run
index d9e5107..3d0ea79 100755
--- a/test/run
+++ b/test/run
@@ -26,6 +26,9 @@ BASEPATH=${BASEPATH:-"$(pwd)"}
 LOGDIR=${LOGDIR:-"${BASEPATH}/test_logs"}
 LOGFILE=${LOGFILE:-"${LOGDIR}/test.log"}
 
+# Location of downloaded guest image files
+IMGDIR=${IMGDIR:-"${BASEPATH}/test_imgs"}
+
 # If set, skip typing delays while issuing commands in panes
 FAST=${FAST:-1}
 
@@ -162,6 +165,7 @@ else
 	rm -rf "${LOGDIR}"
 	mkdir -p "${LOGDIR}"
 	:> "${LOGFILE}"
+	mkdir -p "${IMGDIR}"
 	trap "cleanup" EXIT
 	run_term
 	trap "" EXIT
-- 
@@ -26,6 +26,9 @@ BASEPATH=${BASEPATH:-"$(pwd)"}
 LOGDIR=${LOGDIR:-"${BASEPATH}/test_logs"}
 LOGFILE=${LOGFILE:-"${LOGDIR}/test.log"}
 
+# Location of downloaded guest image files
+IMGDIR=${IMGDIR:-"${BASEPATH}/test_imgs"}
+
 # If set, skip typing delays while issuing commands in panes
 FAST=${FAST:-1}
 
@@ -162,6 +165,7 @@ else
 	rm -rf "${LOGDIR}"
 	mkdir -p "${LOGDIR}"
 	:> "${LOGFILE}"
+	mkdir -p "${IMGDIR}"
 	trap "cleanup" EXIT
 	run_term
 	trap "" EXIT
-- 
2.36.1


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

* [PATCH 4/5] Handle the case of a DNS server on localhost
  2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
                   ` (2 preceding siblings ...)
  2022-06-23  2:22 ` [PATCH 3/5] tests: Cache downloaded guest images David Gibson
@ 2022-06-23  2:22 ` David Gibson
  2022-06-23  2:22 ` [PATCH 5/5] tests: Try multiple paths for aarch64 EDK2 bios image David Gibson
  4 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

By default, passt detects the nameserver used by the host system by reading
/etc/resolv.conf, and advertises that to the guest via DHCP.  However this
breaks down if the host's nameserver is local (on 127.0.0.1 or ::1);
connecting to localhost on the guest won't reach the host's nameserver.

Using a local nameserver is a reasonably common case when using dnsmasq
or similar to merge name resolution on a home network with name resolution
from an organization-private VPN.

We already have the gateway mapping support to allow reaching host-local
services from the guest via the address of the default gateway.  Add code
to detect the case of a local DNS server and use the gateway mapping to
advertise it usefully to the guest.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 conf.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/conf.c b/conf.c
index 22949fd..13cb5a1 100644
--- a/conf.c
+++ b/conf.c
@@ -350,6 +350,14 @@ static void get_dns(struct ctx *c)
 			if (!dns4_set &&
 			    dns4 - &c->dns4[0] < ARRAY_SIZE(c->dns4) - 1 &&
 			    inet_pton(AF_INET, p + 1, dns4)) {
+				/* We can only access local addresses via the gw redirect */
+				if (ntohl(*dns4) >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET) {
+					if (c->no_map_gw) {
+						*dns4 = 0;
+						continue;
+					}
+					*dns4 = c->gw4;
+				}
 				dns4++;
 				*dns4 = 0;
 			}
@@ -357,6 +365,14 @@ static void get_dns(struct ctx *c)
 			if (!dns6_set &&
 			    dns6 - &c->dns6[0] < ARRAY_SIZE(c->dns6) - 1 &&
 			    inet_pton(AF_INET6, p + 1, dns6)) {
+				/* We can only access local addresses via the gw redirect */
+				if (IN6_IS_ADDR_LOOPBACK(dns6)) {
+					if (c->no_map_gw) {
+						memset(dns6, 0, sizeof(*dns6));
+						continue;
+					}
+					memcpy(dns6, &c->gw6, sizeof(*dns6));
+				}
 				dns6++;
 				memset(dns6, 0, sizeof(*dns6));
 			}
-- 
@@ -350,6 +350,14 @@ static void get_dns(struct ctx *c)
 			if (!dns4_set &&
 			    dns4 - &c->dns4[0] < ARRAY_SIZE(c->dns4) - 1 &&
 			    inet_pton(AF_INET, p + 1, dns4)) {
+				/* We can only access local addresses via the gw redirect */
+				if (ntohl(*dns4) >> IN_CLASSA_NSHIFT == IN_LOOPBACKNET) {
+					if (c->no_map_gw) {
+						*dns4 = 0;
+						continue;
+					}
+					*dns4 = c->gw4;
+				}
 				dns4++;
 				*dns4 = 0;
 			}
@@ -357,6 +365,14 @@ static void get_dns(struct ctx *c)
 			if (!dns6_set &&
 			    dns6 - &c->dns6[0] < ARRAY_SIZE(c->dns6) - 1 &&
 			    inet_pton(AF_INET6, p + 1, dns6)) {
+				/* We can only access local addresses via the gw redirect */
+				if (IN6_IS_ADDR_LOOPBACK(dns6)) {
+					if (c->no_map_gw) {
+						memset(dns6, 0, sizeof(*dns6));
+						continue;
+					}
+					memcpy(dns6, &c->gw6, sizeof(*dns6));
+				}
 				dns6++;
 				memset(dns6, 0, sizeof(*dns6));
 			}
-- 
2.36.1


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

* [PATCH 5/5] tests: Try multiple paths for aarch64 EDK2 bios image
  2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
                   ` (3 preceding siblings ...)
  2022-06-23  2:22 ` [PATCH 4/5] Handle the case of a DNS server on localhost David Gibson
@ 2022-06-23  2:22 ` David Gibson
  4 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2022-06-23  2:22 UTC (permalink / raw)
  To: passt-dev

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

Apparently qemu's ARM virt machine needs to be explicitly given a firmware
image, rather than just supplying a sane default.  Unfortunately the EDK2
firmware image we need isn't in the same place on all host distros.

Currently the test scripts hardcode the Debian location, meaning it will
break on hosts that have it somewhere else.  This patch adds a search which
will check both the Debian and Fedora locations, which makes it marginally
more robust.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/distro/debian   |  9 ++++++---
 test/distro/fedora   | 24 ++++++++++++++++--------
 test/distro/opensuse |  3 ++-
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/test/distro/debian b/test/distro/debian
index 6c25f22..b389b9a 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -132,7 +132,8 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 sleep	2
 host	apt-get update
@@ -215,7 +216,8 @@ host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init
 host	guestfish --rw -a __IMG__ -i rm /etc/init.d/cloud-init-local
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
@@ -286,7 +288,8 @@ tempimg	IMG https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-no
 host	virt-edit -a __IMG__ /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --autologin root -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nographic -serial stdio -nodefaults -no-reboot -nographic -vga none __IMG__ -net socket,fd=5 -net nic,model=virtio
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
diff --git a/test/distro/fedora b/test/distro/fedora
index 904c987..718f3c7 100644
--- a/test/distro/fedora
+++ b/test/distro/fedora
@@ -154,7 +154,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -207,7 +208,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -260,7 +262,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -313,7 +316,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -366,7 +370,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -419,7 +424,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -472,7 +478,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
@@ -525,7 +532,8 @@ host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-init-local.se
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/cloud-final.service
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio -device virtio-rng-pci
 host	PS1='$ '
 sleep	2
 host	yum -y install make gcc nmap-ncat
diff --git a/test/distro/opensuse b/test/distro/opensuse
index 617656d..14d6df2 100644
--- a/test/distro/opensuse
+++ b/test/distro/opensuse
@@ -129,7 +129,8 @@ host	wget http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openS
 host	virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 host	ip link set enp0s1 up
 sleep	10
-- 
@@ -129,7 +129,8 @@ host	wget http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openS
 host	virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
-host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio
+hout	BIOS ls /usr/share/qemu-efi-aarch64/QEMU_EFI.fd /usr/share/edk2/aarch64/QEMU_EFI.fd 2>/dev/null || true
+host	./qrap 5 qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios __BIOS__ -nodefaults -nographic -vga none -serial stdio __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
 host	ip link set enp0s1 up
 sleep	10
-- 
2.36.1


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

* Re: [PATCH 2/5] Invoke specific qemu-system-* binaries
  2022-06-23  2:22 ` [PATCH 2/5] Invoke specific qemu-system-* binaries David Gibson
@ 2022-06-28  5:25   ` David Gibson
  0 siblings, 0 replies; 7+ messages in thread
From: David Gibson @ 2022-06-28  5:25 UTC (permalink / raw)
  To: passt-dev

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

On Thu, Jun 23, 2022 at 12:22:55PM +1000, David Gibson wrote:
> A lot of tests and examples invoke qemu with the command "kvm".  However,
> as far as I can tell, "kvm" being aliased to the appropriate qemu system
> binary is Debian specific.  The binary names from qemu upstream -
> qemu-system-$ARCH - also aren't universal, but they are more common (they
> should be good for both Debian and Fedora at least).
> 
> In order to still get KVM acceleration when available, we use the option
> "-M accel=kvm:tcg" to tell qemu to try using either KVM or TCG in that
> order
> 
> A number of the places we invoked "kvm" are expecting specifically an x86
> guest, and so it's also safer to explicitly invoke qemu-system-x86_64.
> 
> Some others appear to be independent of the target arch (just wanting the
> same arch as the host to allow KVM acceleration).  Although I suspect there
> may be more subtle x86 specific options in the qemu command lines, attempt
> to preserve arch independence by using $(uname -m).
> 
> Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>

I found a problem in this patch, now that the mbuto changes have let
be go further in the tests.

[snip]

> diff --git a/test/lib/setup b/test/lib/setup
> index e57d97c..0b6d915 100755
> --- a/test/lib/setup
> +++ b/test/lib/setup
> @@ -58,7 +58,8 @@ setup_passt() {
>  	pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid"
>  	sleep 5
>  
> -	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
> +	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
> +		'-m '${VMEM}' -cpu host -smp '${VCPUS}                     \

I forgot to specify the KVM accelerator in these changes, which makes
qemu die with an error because !KVM is incompatible with -cpu host.

I've fixed this locally in my tree, but I'm trying to sort out some
other issues before reposting the series.

>  		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
>  		' -initrd mbuto.img -nographic -serial stdio'		   \
>  		' -nodefaults'						   \
> @@ -170,7 +171,9 @@ setup_passt_in_ns() {
>  	fi
>  	sleep 5
>  
> -	pane_run GUEST './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
> +	pane_run GUEST './qrap 5 qemu-system-$(uname -m)'                  \
> +		' -M accel=kvm:tcg'                                        \
> +		' -m '${VMEM}' -cpu host -smp '${VCPUS}                    \
>  		' -kernel ' "/boot/vmlinuz-$(uname -r)"			   \
>  		' -initrd mbuto.img -nographic -serial stdio'		   \
>  		' -nodefaults'						   \
> @@ -259,7 +262,9 @@ setup_two_guests() {
>  	pane_run GUEST_2 'cp mbuto.img mbuto_2.img'
>  	pane_status GUEST_2
>  
> -	pane_run GUEST_1 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
> +	pane_run GUEST_1 './qrap 5 qemu-system-$(uname -m)'                  \
> +		' -M accel=kvm:tcg'                                          \
> +		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
>  		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
>  		' -initrd mbuto.img -nographic -serial stdio'		     \
>  		' -nodefaults'						     \
> @@ -267,7 +272,9 @@ setup_two_guests() {
>  		'virtio-net.napi_tx=1"'					     \
>  		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
>  		" -netdev socket,fd=5,id=hostnet0"
> -	pane_run GUEST_2 './qrap 5 kvm -m '${VMEM}' -cpu host -smp '${VCPUS} \
> +	pane_run GUEST_2 './qrap 5 qemu-system-$(uname -m)'                  \
> +		' -M accel=kvm:tcg'                                          \
> +		' -m '${VMEM}' -cpu host -smp '${VCPUS}                      \
>  		' -kernel ' "/boot/vmlinuz-$(uname -r)"			     \
>  		' -initrd mbuto_2.img -nographic -serial stdio'		     \
>  		' -nodefaults'						     \

-- 
David Gibson			| 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] 7+ messages in thread

end of thread, other threads:[~2022-06-28  5:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23  2:22 [PATCH 0/5] Test fixes, batch 3 David Gibson
2022-06-23  2:22 ` [PATCH 1/5] tests: qemu-system-ppc64le isn't a thing David Gibson
2022-06-23  2:22 ` [PATCH 2/5] Invoke specific qemu-system-* binaries David Gibson
2022-06-28  5:25   ` David Gibson
2022-06-23  2:22 ` [PATCH 3/5] tests: Cache downloaded guest images David Gibson
2022-06-23  2:22 ` [PATCH 4/5] Handle the case of a DNS server on localhost David Gibson
2022-06-23  2:22 ` [PATCH 5/5] tests: Try multiple paths for aarch64 EDK2 bios image David Gibson

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