diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-12-21 18:06:22 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-12-21 18:06:22 +0100 |
| commit | 6fa36ec9957501e9e917a345fb93a8d95786199d (patch) | |
| tree | 4a63978c80eacf211b1fc3fed1c3e5cbb237676f /scripts | |
| parent | d21ca283b02a8959c8de24411ecb33efb9b79172 (diff) | |
| download | vyos-build-6fa36ec9957501e9e917a345fb93a8d95786199d.tar.gz vyos-build-6fa36ec9957501e9e917a345fb93a8d95786199d.zip | |
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.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-qemu-install | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 7e55a5a7..07e59fc5 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -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) |
