Testsuite: T8111: make --iso and --disk optional arguments

It is now possible to pass in an already existing qcow2 disk image to the
Testsuite. This is necessary if we would like to boot wxisting flavor images
like KVM or PROXMOX.
This commit is contained in:
Christian Breunig 2025-12-21 18:06:22 +01:00
parent d21ca283b0
commit 6fa36ec995
2 changed files with 35 additions and 23 deletions

View file

@ -21,37 +21,37 @@ checkiso:
.PHONY: test
.ONESHELL:
test: checkiso
scripts/check-qemu-install --debug --configd --match="$(MATCH)" --smoketest --uefi --cpu 4 --memory 8 build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
scripts/check-qemu-install --debug --configd --match="$(MATCH)" --smoketest --uefi --cpu 4 --memory 8 --iso build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
.PHONY: test-no-interfaces
.ONESHELL:
test-no-interfaces: checkiso
scripts/check-qemu-install --debug --configd --smoketest --uefi --no-interfaces --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 build/live-image-amd64.hybrid.iso
scripts/check-qemu-install --debug --configd --smoketest --uefi --no-interfaces --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --iso build/live-image-amd64.hybrid.iso
.PHONY: test-no-interfaces-no-vpp
.ONESHELL:
test-no-interfaces-no-vpp: checkiso
scripts/check-qemu-install --debug --configd --smoketest --uefi --no-interfaces --no-vpp build/live-image-amd64.hybrid.iso
scripts/check-qemu-install --debug --configd --smoketest --uefi --no-interfaces --no-vpp --iso build/live-image-amd64.hybrid.iso
.PHONY: test-interfaces
.ONESHELL:
test-interfaces: checkiso
scripts/check-qemu-install --debug --configd --match="interfaces_" --smoketest --uefi build/live-image-amd64.hybrid.iso
scripts/check-qemu-install --debug --configd --match="interfaces_" --smoketest --uefi --iso build/live-image-amd64.hybrid.iso
.PHONY: test-vpp
.ONESHELL:
test-vpp: checkiso
scripts/check-qemu-install --debug --configd --match="vpp" --smoketest --uefi --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 build/live-image-amd64.hybrid.iso
scripts/check-qemu-install --debug --configd --match="vpp" --smoketest --uefi --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --iso build/live-image-amd64.hybrid.iso
.PHONY: testc
.ONESHELL:
testc: checkiso
scripts/check-qemu-install --debug --configd --match="!vpp" --cpu 2 --memory 7 --configtest build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
scripts/check-qemu-install --debug --configd --match="!vpp" --cpu 2 --memory 7 --configtest --iso build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
.PHONY: testcvpp
.ONESHELL:
testcvpp: checkiso
scripts/check-qemu-install --debug --configd --match="vpp" --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --configtest build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
scripts/check-qemu-install --debug --configd --match="vpp" --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --configtest --iso build/live-image-amd64.hybrid.iso $(filter-out $@,$(MAKECMDGOALS))
.PHONY: testraid
.ONESHELL:

View file

@ -51,7 +51,8 @@ import tomli
import pexpect
EXCEPTION = 0
now = datetime.now()
DISK_IMAGE_EXTENSION = '.raw'
tpm_folder = '/tmp/vyos_tpm_test'
qemu_name = 'VyOS-QEMU'
@ -68,10 +69,8 @@ KEY_Y = chr(121)
mok_password = '1234'
parser = argparse.ArgumentParser(description='Install and start a test VyOS vm.')
parser.add_argument('iso', help='ISO file to install')
parser.add_argument('disk', help='name of disk image file', nargs='?',
default='testinstall-{}-{}.img'.format(now.strftime('%Y%m%d-%H%M%S'),
"%04x" % random.randint(0,65535)))
parser.add_argument('--iso', help='ISO file to install')
parser.add_argument('--disk', help='name of disk image file', nargs='?')
parser.add_argument('--keep', help='Do not remove disk-image after installation',
action='store_true', default=False)
parser.add_argument('--silent', help='Do not show output on stdout unless an error has occured',
@ -142,10 +141,6 @@ class StreamToLogger(object):
def flush(self):
pass
OVMF_CODE = '/usr/share/OVMF/OVMF_CODE_4M.secboot.fd'
OVMF_VARS_TMP = args.disk.replace('.img', '.efivars')
if args.sbtest:
shutil.copy('/usr/share/OVMF/OVMF_VARS_4M.ms.fd', OVMF_VARS_TMP)
def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False, vnc_enabled=False, secure_boot=False):
uefi = ""
@ -178,6 +173,10 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False
# RFC7042 section 2.1.2 MAC addresses used for documentation
macbase = '00:00:5E:00:53'
# Set QEmu disk image format - this differs if VyOS was installed via smoketest
# or we use an already ewxisting image
disk_format = 'qcow2' if args.disk.endswith('.qcow2') else 'raw'
cmd = f'qemu-system-x86_64 \
-name "{name}" \
-smp {args.cpu},sockets=1,cores={args.cpu},threads=1 \
@ -200,11 +199,11 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False
-netdev user,id=n6 -device virtio-net-pci,netdev=n6,mac={macbase}:06,romfile="" \
-netdev user,id=n7 -device virtio-net-pci,netdev=n7,mac={macbase}:07,romfile="" \
-device virtio-scsi-pci,id=scsi0 \
-drive format=raw,file={disk_img},if=none,media=disk,id=drive-hd1,readonly=off \
-drive format={disk_format},file={disk_img},if=none,media=disk,id=drive-hd1,readonly=off \
-device scsi-hd,bus=scsi0.0,drive=drive-hd1,id=hd1,bootindex=1'
if raid:
cmd += f' -drive format=raw,file={raid},if=none,media=disk,id=drive-hd2,readonly=off' \
cmd += f' -drive format={disk_format},file={raid},if=none,media=disk,id=drive-hd2,readonly=off' \
f' -device scsi-hd,bus=scsi0.0,drive=drive-hd2,id=hd2,bootindex=2'
if tpm:
@ -276,14 +275,27 @@ if args.silent:
else:
output = sys.stdout.buffer
if not os.path.isfile(args.iso):
log.error('Unable to find iso image to install')
sys.exit(1)
if not os.path.exists('/dev/kvm'):
log.error('KVM not enabled on host, proceeding with software emulation')
sys.exit(1)
if not args.iso and not args.disk:
log.error('Neither ISO not QCOW2 disk image supplied - error!')
sys.exit(1)
if not args.disk:
tmp_disk_time = datetime.now().strftime('%Y%m%d-%H%M%S')
tmp_disk_random = "%04x" % random.randint(0,65535)
args.disk = f'testinstall-{tmp_disk_time}-{tmp_disk_random}{DISK_IMAGE_EXTENSION}'
if not args.iso or not os.path.isfile(args.iso):
log.debug('Unable to find ISO image to install ...')
OVMF_CODE = '/usr/share/OVMF/OVMF_CODE_4M.secboot.fd'
OVMF_VARS_TMP = args.disk.replace(DISK_IMAGE_EXTENSION, '.efivars')
if args.sbtest:
shutil.copy('/usr/share/OVMF/OVMF_VARS_4M.ms.fd', OVMF_VARS_TMP)
# Creating diskimage!!
diskname_raid = None
def gen_disk(name):
@ -292,7 +304,7 @@ def gen_disk(name):
c = subprocess.check_output(['qemu-img', 'create', name, '2G'])
log.debug(c.decode())
else:
log.info(f'Diskimage "{name}" already exists, using the existing one.')
log.info(f'Re-using already existing disk image "{name}".')
if args.raid:
filename, ext = os.path.splitext(args.disk)