diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-01-15 15:42:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-15 15:42:01 +0000 |
| commit | f43677194feecaeabdecdc53d0aec5de649c874b (patch) | |
| tree | a5ce78b25412a691e9d6bb67622817217a8ce194 /scripts | |
| parent | 02a787d1eb19b51403f9936808fa13d230aa62aa (diff) | |
| parent | d557ef0a6967a94e45243db6e7dbf0ad27add4bf (diff) | |
| download | vyos-build-f43677194feecaeabdecdc53d0aec5de649c874b.tar.gz vyos-build-f43677194feecaeabdecdc53d0aec5de649c874b.zip | |
Merge pull request #1092 from sever-sever/T8065-v2
T8065: Dehardcode qemu settings to allow run tests on arch arm64
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/check-qemu-install | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 5f96cec6..ced0f3fb 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -82,8 +82,23 @@ KEY_Y = chr(121) mok_password = '1234' +# Map QEMU arch +QEMU_CONFIG = { + "amd64": { + "bin": "qemu-system-x86_64", + "machine": "pc", + "bios": "/usr/share/OVMF/OVMF_CODE.fd", + }, + "arm64": { + "bin": "qemu-system-aarch64", + "machine": "virt", + "bios": "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd", + }, +} + parser = argparse.ArgumentParser(description='Install and start a test VyOS vm.') parser.add_argument('--iso', help='ISO file to install') +parser.add_argument('--arch', help='Architecture') 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) @@ -113,6 +128,7 @@ parser.add_argument('--cloud-init', help='Execute cloud-init tests', parser.add_argument('--qemu-cmd', help='Only generate QEMU launch command', action='store_true', default=False) parser.add_argument('--cpu', help='Set QEMU CPU', type=int, default=2) +parser.add_argument('--cpu-type', help='Set QEMU CPU type', type=str, default='host') parser.add_argument('--memory', help='Set QEMU memory', type=int, default=4) parser.add_argument('--vyconf', help='Execute testsuite with vyconfd', action='store_true', default=False) @@ -165,10 +181,20 @@ class StreamToLogger(object): class EarlyExit(Exception): pass +def _kvm_exists(): + return os.path.exists("/dev/kvm") + def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False, vnc_enabled=False, secure_boot=False): uefi = "" uuid = "f48b60b2-e6ad-49ef-9d09-4245d0585e52" - machine = 'pc' + accel = ',accel=kvm' if _kvm_exists() else '' + arch = getattr(args, 'arch', 'amd64') + qemu_arch_config = QEMU_CONFIG.get(arch, QEMU_CONFIG['amd64']) + qemu_bin = qemu_arch_config['bin'] + bios = qemu_arch_config['bios'] + cpu_type = args.cpu_type + enable_kvm = '-enable-kvm' if _kvm_exists() else '' + machine = qemu_arch_config['machine'] vga = '-vga none' vnc = '' if vnc_enabled: @@ -176,7 +202,7 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False vnc = '-vnc :0' if enable_uefi: - uefi = '-bios /usr/share/OVMF/OVMF_CODE.fd' + uefi = f'-bios {bios}' name = f'{name}-UEFI' if secure_boot: @@ -194,24 +220,29 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False f' -device ahci,id=achi0' \ f' -device ide-cd,bus=achi0.0,drive=drive-cd1,id=cd1,bootindex=10' + if arch == 'arm64': + cdrom = ( + f' -drive file={iso_img},format=raw,if=none,media=cdrom,id=drive-cd1,readonly=on' + f' -device scsi-cd,bus=scsi0.0,drive=drive-cd1,id=cd1,bootindex=10' + ) + # 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 \ + cmd = f'{qemu_bin} \ -name "{name}" \ -smp {args.cpu},sockets=1,cores={args.cpu},threads=1 \ - -cpu host \ - -machine {machine},accel=kvm \ + -cpu {cpu_type} \ + -machine {machine}{accel} \ {uefi} \ -m {args.memory}G \ -nographic \ {vga} {vnc}\ -uuid {uuid} \ - {cdrom} \ - -enable-kvm \ + {enable_kvm} \ -monitor unix:/tmp/qemu-monitor-socket-{disk_img},server,nowait \ -netdev user,id=n0,net=192.0.2.0/24,dhcpstart=192.0.2.101,dns=192.0.2.10 -device virtio-net-pci,netdev=n0,mac={macbase}:00,romfile="",host_mtu=1500 \ -netdev user,id=n1 -device virtio-net-pci,netdev=n1,mac={macbase}:01,romfile="",host_mtu=1500 \ @@ -222,6 +253,7 @@ 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 \ + {cdrom} \ -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' @@ -300,7 +332,6 @@ else: 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!') @@ -484,9 +515,9 @@ def basic_cli_tests(c): c.expect(op_mode_prompt) c.sendline('show interfaces') c.expect(op_mode_prompt) - c.sendline('systemd-detect-virt') - c.expect('kvm') - c.expect(op_mode_prompt) + # c.sendline('systemd-detect-virt') + # c.expect('kvm') + # c.expect(op_mode_prompt) c.sendline('show system cpu') c.expect(op_mode_prompt) c.sendline('show system memory') |
