def test_virtio_vga_virgl(self): """ :avocado: tags=arch:x86_64 :avocado: tags=device:virtio-vga """ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + "console=ttyS0 rdinit=/bin/bash") # FIXME: should check presence of virtio, virgl etc if not kvm_available(self.arch, self.qemu_bin): self.cancel(KVM_NOT_AVAILABLE) kernel_path = self.fetch_asset(self.KERNEL_URL) initrd_path = self.fetch_asset(self.INITRD_URL) self.vm.set_console() self.vm.add_args("-cpu", "host") self.vm.add_args("-m", "2G") self.vm.add_args("-machine", "pc,accel=kvm") self.vm.add_args("-device", "virtio-vga,virgl=on") self.vm.add_args("-display", "egl-headless") self.vm.add_args( "-kernel", kernel_path, "-initrd", initrd_path, "-append", kernel_command_line, ) self.vm.launch() self.wait_for_console_pattern("as init process") exec_command_and_wait_for_pattern(self, "/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl +edid")
def test_ppc_bamboo(self): """ :avocado: tags=arch:ppc :avocado: tags=machine:bamboo :avocado: tags=cpu:440epb :avocado: tags=device:rtl8139 :avocado: tags=accel:tcg """ self.require_accelerator("tcg") tar_url = ('http://landley.net/aboriginal/downloads/binaries/' 'system-image-powerpc-440fp.tar.gz') tar_hash = '53e5f16414b195b82d2c70272f81c2eedb39bad9' file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) archive.extract(file_path, self.workdir) self.vm.set_console() self.vm.add_args( '-kernel', self.workdir + '/system-image-powerpc-440fp/linux', '-initrd', self.workdir + '/system-image-powerpc-440fp/rootfs.cpio.gz', '-nic', 'user,model=rtl8139,restrict=on') self.vm.launch() wait_for_console_pattern(self, 'Type exit when done') exec_command_and_wait_for_pattern(self, 'ping 10.0.2.2', '10.0.2.2 is alive!') exec_command_and_wait_for_pattern(self, 'halt', 'System Halted')
def test_virtio_vga_virgl(self): """ :avocado: tags=device:virtio-vga-gl """ # FIXME: should check presence of virtio, virgl etc self.require_accelerator('kvm') kernel_path = self.fetch_asset(self.KERNEL_URL, self.KERNEL_HASH) initrd_path = self.fetch_asset(self.INITRD_URL, self.INITRD_HASH) self.vm.set_console() self.vm.add_args("-m", "2G") self.vm.add_args("-machine", "pc,accel=kvm") self.vm.add_args("-device", "virtio-vga-gl") self.vm.add_args("-display", "egl-headless") self.vm.add_args( "-kernel", kernel_path, "-initrd", initrd_path, "-append", self.KERNEL_COMMAND_LINE, ) try: self.vm.launch() except: # TODO: probably fails because we are missing the VirGL features self.cancel("VirGL not enabled?") self.wait_for_console_pattern("as init process") exec_command_and_wait_for_pattern(self, "/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl +edid")
def test_arm_ast2600_evb_builroot(self): """ :avocado: tags=arch:arm :avocado: tags=machine:ast2600-evb """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' 'images/ast2600-evb/buildroot-2022.05/flash.img') image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') self.vm.add_args('-device', 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); self.vm.add_args('-device', 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); self.do_test_arm_aspeed_buidroot_start(image_path, '0xf00') exec_command_and_wait_for_pattern(self, 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon0/temp1_input', '0') self.vm.command('qom-set', path='/machine/peripheral/tmp-test', property='temperature', value=18000); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000') exec_command_and_wait_for_pattern(self, 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32'); year = time.strftime("%Y") exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); self.do_test_arm_aspeed_buidroot_poweroff()
def test_arm_emcraft_sf2(self): """ :avocado: tags=arch:arm :avocado: tags=machine:emcraft-sf2 :avocado: tags=endian:little :avocado: tags=u-boot """ uboot_url = ('https://raw.githubusercontent.com/' 'Subbaraya-Sundeep/qemu-test-binaries/' 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot') uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2' uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) spi_url = ('https://raw.githubusercontent.com/' 'Subbaraya-Sundeep/qemu-test-binaries/' 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin') spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501' spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE self.vm.add_args('-kernel', uboot_path, '-append', kernel_command_line, '-drive', 'file=' + spi_path + ',if=mtd,format=raw', '-no-reboot') self.vm.launch() self.wait_for_console_pattern('Enter \'help\' for a list') exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', 'eth0: link becomes ready') exec_command_and_wait_for_pattern( self, 'ping -c 3 10.0.2.2', '3 packets transmitted, 3 packets received, 0% packet loss')
def test_vhost_user_vga_virgl(self): """ :avocado: tags=device:vhost-user-vga """ # FIXME: should check presence of vhost-user-gpu, virgl, memfd etc self.require_accelerator('kvm') vug = pick_default_vug_bin() if not vug: self.cancel("Could not find vhost-user-gpu") kernel_path = self.fetch_asset(self.KERNEL_URL, self.KERNEL_HASH) initrd_path = self.fetch_asset(self.INITRD_URL, self.INITRD_HASH) # Create socketpair to connect proxy and remote processes qemu_sock, vug_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) os.set_inheritable(qemu_sock.fileno(), True) os.set_inheritable(vug_sock.fileno(), True) self._vug_log_path = os.path.join(self.logdir, "vhost-user-gpu.log") self._vug_log_file = open(self._vug_log_path, "wb") self.log.info('Complete vhost-user-gpu.log file can be ' 'found at %s', self._vug_log_path) vugp = subprocess.Popen( [vug, "--virgl", "--fd=%d" % vug_sock.fileno()], stdin=subprocess.DEVNULL, stdout=self._vug_log_file, stderr=subprocess.STDOUT, shell=False, close_fds=False, ) self.vm.set_console() self.vm.add_args("-m", "2G") self.vm.add_args("-object", "memory-backend-memfd,id=mem,size=2G") self.vm.add_args("-machine", "pc,memory-backend=mem,accel=kvm") self.vm.add_args("-chardev", "socket,id=vug,fd=%d" % qemu_sock.fileno()) self.vm.add_args("-device", "vhost-user-vga,chardev=vug") self.vm.add_args("-display", "egl-headless") self.vm.add_args( "-kernel", kernel_path, "-initrd", initrd_path, "-append", self.KERNEL_COMMAND_LINE, ) self.vm.launch() self.wait_for_console_pattern("as init process") exec_command_and_wait_for_pattern(self, "/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl -edid") self.vm.shutdown() qemu_sock.close() vugp.terminate() vugp.wait()
def do_test_ppc405(self): uboot_url = ('https://gitlab.com/huth/u-boot/-/raw/' 'taihu-2021-10-09/u-boot-taihu.bin') uboot_hash = ('3208940e908a5edc7c03eab072c60f0dcfadc2ab'); file_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) self.vm.set_console(console_index=1) self.vm.add_args('-bios', file_path) self.vm.launch() wait_for_console_pattern(self, 'AMCC PPC405EP Evaluation Board') exec_command_and_wait_for_pattern(self, 'reset', 'AMCC PowerPC 405EP')
def test_ast1030_zephyros(self): """ :avocado: tags=arch:arm :avocado: tags=machine:ast1030-evb """ tar_url = ('https://github.com/AspeedTech-BMC' '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip') tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20' tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) archive.extract(tar_path, self.workdir) kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf" self.vm.set_console() self.vm.add_args('-kernel', kernel_file, '-nographic') self.vm.launch() wait_for_console_pattern(self, "Booting Zephyr OS") exec_command_and_wait_for_pattern(self, "help", "Available commands")
def test_arm_quanta_gsj(self): """ :avocado: tags=arch:arm :avocado: tags=machine:quanta-gsj """ # 25 MiB compressed, 32 MiB uncompressed. image_url = ( 'https://github.com/hskinnemoen/openbmc/releases/download/' '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz') image_hash = '14895e634923345cb5c8776037ff7876df96f6b1' image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) image_name = 'obmc.mtd' image_path = os.path.join(self.workdir, image_name) archive.gzip_uncompress(image_path_gz, image_path) self.vm.set_console() drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0' self.vm.add_args('-drive', drive_args) self.vm.launch() # Disable drivers and services that stall for a long time during boot, # to avoid running past the 90-second timeout. These may be removed # as the corresponding device support is added. kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + ( 'console=${console} ' 'mem=${mem} ' 'initcall_blacklist=npcm_i2c_bus_driver_init ' 'systemd.mask=systemd-random-seed.service ' 'systemd.mask=dropbearkey.service ' ) self.wait_for_console_pattern('> BootBlock by Nuvoton') self.wait_for_console_pattern('>Device: Poleg BMC NPCM730') self.wait_for_console_pattern('>Skip DDR init.') self.wait_for_console_pattern('U-Boot ') interrupt_interactive_console_until_pattern( self, 'Hit any key to stop autoboot:', 'U-Boot>') exec_command_and_wait_for_pattern( self, "setenv bootargs ${bootargs} " + kernel_command_line, 'U-Boot>') exec_command_and_wait_for_pattern( self, 'run romboot', 'Booting Kernel from flash') self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') self.wait_for_console_pattern('OpenBMC Project Reference Distro') self.wait_for_console_pattern('gsj login:')
def do_test(self, kernel_url, initrd_url, kernel_command_line, machine_type): """Main test method""" self.require_accelerator('kvm') # Create socketpair to connect proxy and remote processes proxy_sock, remote_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) os.set_inheritable(proxy_sock.fileno(), True) os.set_inheritable(remote_sock.fileno(), True) kernel_path = self.fetch_asset(kernel_url) initrd_path = self.fetch_asset(initrd_url) # Create remote process remote_vm = self.get_vm() remote_vm.add_args('-machine', 'x-remote') remote_vm.add_args('-nodefaults') remote_vm.add_args('-device', 'lsi53c895a,id=lsi1') remote_vm.add_args( '-object', 'x-remote-object,id=robj1,' 'devid=lsi1,fd=' + str(remote_sock.fileno())) remote_vm.launch() # Create proxy process self.vm.set_console() self.vm.add_args('-machine', machine_type) self.vm.add_args('-accel', 'kvm') self.vm.add_args('-cpu', 'host') self.vm.add_args('-object', 'memory-backend-memfd,id=sysmem-file,size=2G') self.vm.add_args('--numa', 'node,memdev=sysmem-file') self.vm.add_args('-m', '2048') self.vm.add_args('-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line) self.vm.add_args( '-device', 'x-pci-proxy-dev,' 'id=lsi1,fd=' + str(proxy_sock.fileno())) self.vm.launch() wait_for_console_pattern(self, 'as init process', 'Kernel panic - not syncing') exec_command(self, 'mount -t sysfs sysfs /sys') exec_command_and_wait_for_pattern(self, 'cat /sys/bus/pci/devices/*/uevent', 'PCI_ID=1000:0012')
def test_arm_cubieboard_sata(self): """ :avocado: tags=arch:arm :avocado: tags=machine:cubieboard """ deb_url = ('https://apt.armbian.com/pool/main/l/' 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-4.20.7-sunxi') dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' dtb_path = self.extract_from_deb(deb_path, dtb_path) rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 'arm/rootfs-armv5.ext2.gz') rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93' rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') archive.gzip_uncompress(rootfs_path_gz, rootfs_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'usbcore.nousb ' 'root=/dev/sda ro ' 'panic=-1 noreboot') self.vm.add_args('-kernel', kernel_path, '-dtb', dtb_path, '-drive', 'if=none,format=raw,id=disk0,file=' + rootfs_path, '-device', 'ide-hd,bus=ide.0,drive=disk0', '-append', kernel_command_line, '-no-reboot') self.vm.launch() self.wait_for_console_pattern('Boot successful.') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'Allwinner sun4i/sun5i') exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', 'sda')
def test_arm_ast2500_evb_builroot(self): """ :avocado: tags=arch:arm :avocado: tags=machine:ast2500-evb """ image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' 'images/ast2500-evb/buildroot-2022.05/flash.img') image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') self.vm.add_args('-device', 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); self.do_test_arm_aspeed_buidroot_start(image_path, '0x0') exec_command_and_wait_for_pattern(self, 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') self.vm.command('qom-set', path='/machine/peripheral/tmp-test', property='temperature', value=18000); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') self.do_test_arm_aspeed_buidroot_poweroff()
def test_mips_malta_cpio(self): """ :avocado: tags=arch:mips :avocado: tags=machine:malta :avocado: tags=endian:big """ deb_url = ('http://snapshot.debian.org/archive/debian/' '20160601T041800Z/pool/main/l/linux/' 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb') deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinux-4.5.0-2-4kc-malta') initrd_url = ('https://github.com/groeck/linux-build-test/raw/' '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' 'mips/rootfs.cpio.gz') initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99' initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) initrd_path = self.workdir + "rootfs.cpio" archive.gzip_uncompress(initrd_path_gz, initrd_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0 console=tty ' + 'rdinit=/sbin/init noreboot') self.vm.add_args('-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line, '-no-reboot') self.vm.launch() self.wait_for_console_pattern('Boot successful.') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'BogoMIPS') exec_command_and_wait_for_pattern(self, 'uname -a', 'Debian') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system')
def test_arm_cubieboard_initrd(self): """ :avocado: tags=arch:arm :avocado: tags=machine:cubieboard """ deb_url = ('https://apt.armbian.com/pool/main/l/' 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-4.20.7-sunxi') dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' dtb_path = self.extract_from_deb(deb_path, dtb_path) initrd_url = ('https://github.com/groeck/linux-build-test/raw/' '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 'arm/rootfs-armv5.cpio.gz') initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) initrd_path = os.path.join(self.workdir, 'rootfs.cpio') archive.gzip_uncompress(initrd_path_gz, initrd_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'usbcore.nousb ' 'panic=-1 noreboot') self.vm.add_args('-kernel', kernel_path, '-dtb', dtb_path, '-initrd', initrd_path, '-append', kernel_command_line, '-no-reboot') self.vm.launch() self.wait_for_console_pattern('Boot successful.') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'Allwinner sun4i/sun5i') exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 'system-control@1c00000')
def test_linux_sash(self): """ Boots a Linux kernel and checks that the console is operational. :avocado: tags=arch:rx :avocado: tags=machine:gdbsim-r5f562n7 :avocado: tags=endian:little """ dtb_url = ('https://acc.dl.osdn.jp/users/23/23887/rx-virt.dtb') dtb_hash = '7b4e4e2c71905da44e86ce47adee2210b026ac18' dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash) kernel_url = ('http://acc.dl.osdn.jp/users/23/23845/zImage') kernel_hash = '39a81067f8d72faad90866ddfefa19165d68fc99' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon' self.vm.add_args('-kernel', kernel_path, '-dtb', dtb_path, '-no-reboot') self.vm.launch() wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)', failure_message='Kernel panic - not syncing') exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux')
def test_arm_orangepi_bionic_20_08(self): """ :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd """ # This test download a 275 MiB compressed image and expand it # to 1036 MiB, but the underlying filesystem is 1552 MiB... # As we expand it to 2 GiB we are safe. image_url = ('https://archive.armbian.com/orangepipc/archive/' 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') image_hash = ('b4d6775f5673486329e45a0586bf06b6' 'dbe792199fd182ac6b9c7bb6c7d3e6dd') image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') image_path = archive.extract(image_path_xz, self.workdir) image_pow2ceil_expand(image_path) self.vm.set_console() self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', '-nic', 'user', '-no-reboot') self.vm.launch() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'loglevel=7 ' 'nosmp ' 'systemd.default_timeout_start_sec=9000 ' 'systemd.mask=armbian-zram-config.service ' 'systemd.mask=armbian-ramlog.service') self.wait_for_console_pattern('U-Boot SPL') self.wait_for_console_pattern('Autoboot in ') exec_command_and_wait_for_pattern(self, ' ', '=>') exec_command_and_wait_for_pattern( self, "setenv extraargs '" + kernel_command_line + "'", '=>') exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...') self.wait_for_console_pattern('systemd[1]: Set hostname ' + 'to <orangepipc>') self.wait_for_console_pattern('Starting Load Kernel Modules...')
def test_arm_orangepi_initrd(self): """ :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc """ deb_url = ('https://apt.armbian.com/pool/main/l/' 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-4.20.7-sunxi') dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' dtb_path = self.extract_from_deb(deb_path, dtb_path) initrd_url = ('https://github.com/groeck/linux-build-test/raw/' '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 'arm/rootfs-armv7a.cpio.gz') initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) initrd_path = os.path.join(self.workdir, 'rootfs.cpio') archive.gzip_uncompress(initrd_path_gz, initrd_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'panic=-1 noreboot') self.vm.add_args('-kernel', kernel_path, '-dtb', dtb_path, '-initrd', initrd_path, '-append', kernel_command_line, '-no-reboot') self.vm.launch() self.wait_for_console_pattern('Boot successful.') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'Allwinner sun8i Family') exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', 'system-control@1c00000') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') # Wait for VM to shut down gracefully self.vm.wait()
def test_arm_orangepi_bionic(self): """ :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc :avocado: tags=device:sd """ # This test download a 196MB compressed image and expand it to 1GB image_url = ('https://dl.armbian.com/orangepipc/archive/' 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e' image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash) image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img' image_path = os.path.join(self.workdir, image_name) process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) image_pow2ceil_expand(image_path) self.vm.set_console() self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', '-nic', 'user', '-no-reboot') self.vm.launch() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'loglevel=7 ' 'nosmp ' 'systemd.default_timeout_start_sec=9000 ' 'systemd.mask=armbian-zram-config.service ' 'systemd.mask=armbian-ramlog.service') self.wait_for_console_pattern('U-Boot SPL') self.wait_for_console_pattern('Autoboot in ') exec_command_and_wait_for_pattern(self, ' ', '=>') exec_command_and_wait_for_pattern(self, "setenv extraargs '" + kernel_command_line + "'", '=>') exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); self.wait_for_console_pattern('systemd[1]: Set hostname ' + 'to <orangepipc>') self.wait_for_console_pattern('Starting Load Kernel Modules...')
def test_mips64el_malta_5KEc_cpio(self): """ :avocado: tags=arch:mips64el :avocado: tags=machine:malta :avocado: tags=endian:little """ kernel_url = ('https://github.com/philmd/qemu-testing-blob/' 'raw/9ad2df38/mips/malta/mips64el/' 'vmlinux-3.19.3.mtoman.20150408') kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) initrd_url = ('https://github.com/groeck/linux-build-test/' 'raw/8584a59e/rootfs/' 'mipsel64/rootfs.mipsel64r1.cpio.gz') initrd_hash = '1dbb8a396e916847325284dbe2151167' initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5', asset_hash=initrd_hash) initrd_path = self.workdir + "rootfs.cpio" archive.gzip_uncompress(initrd_path_gz, initrd_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0 console=tty ' + 'rdinit=/sbin/init noreboot') self.vm.add_args('-cpu', '5KEc', '-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line, '-no-reboot') self.vm.launch() wait_for_console_pattern(self, 'Boot successful.') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'MIPS 5KE') exec_command_and_wait_for_pattern(self, 'uname -a', '3.19.3.mtoman.20150408') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') # Wait for VM to shut down gracefully self.vm.wait()
def do_test_arm_aspeed_buidroot_poweroff(self): exec_command_and_wait_for_pattern(self, 'poweroff', 'reboot: System halted');
def test_arm_orangepi_sd(self): """ :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc """ deb_url = ('https://apt.armbian.com/pool/main/l/' 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-4.20.7-sunxi') dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' dtb_path = self.extract_from_deb(deb_path, dtb_path) rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' 'kci-2019.02/armel/base/rootfs.ext2.xz') rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061' rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') archive.lzma_uncompress(rootfs_path_xz, rootfs_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0,115200 ' 'root=/dev/mmcblk0 rootwait rw ' 'panic=-1 noreboot') self.vm.add_args('-kernel', kernel_path, '-dtb', dtb_path, '-drive', 'file=' + rootfs_path + ',if=sd,format=raw', '-append', kernel_command_line, '-no-reboot') self.vm.launch() shell_ready = "/bin/sh: can't access tty; job control turned off" self.wait_for_console_pattern(shell_ready) exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'Allwinner sun8i Family') exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', 'mmcblk0') exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', 'eth0: Link is Up') exec_command_and_wait_for_pattern( self, 'udhcpc eth0', 'udhcpc: lease of 10.0.2.15 obtained') exec_command_and_wait_for_pattern( self, 'ping -c 3 10.0.2.2', '3 packets transmitted, 3 packets received, 0% packet loss') exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system')
def wait_for_crw_reports(self): exec_command_and_wait_for_pattern( self, 'while ! (dmesg -c | grep CRW) ; do sleep 1 ; done', 'CRW reports')
def test_s390x_fedora(self): """ :avocado: tags=arch:s390x :avocado: tags=machine:s390-ccw-virtio :avocado: tags=device:virtio-gpu :avocado: tags=device:virtio-crypto :avocado: tags=device:virtio-net """ kernel_url = ('https://archives.fedoraproject.org/pub/archive' '/fedora-secondary/releases/31/Server/s390x/os' '/images/kernel.img') kernel_hash = 'b93d1efcafcf29c1673a4ce371a1f8b43941cfeb' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) initrd_url = ('https://archives.fedoraproject.org/pub/archive' '/fedora-secondary/releases/31/Server/s390x/os' '/images/initrd.img') initrd_hash = '3de45d411df5624b8d8ef21cd0b44419ab59b12f' initrd_path_xz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) initrd_path = os.path.join(self.workdir, 'initrd-raw.img') archive.lzma_uncompress(initrd_path_xz, initrd_path) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + ' audit=0 ' 'rd.plymouth=0 plymouth.enable=0 rd.rescue') self.vm.add_args('-nographic', '-smp', '4', '-m', '512', '-name', 'Some Guest Name', '-uuid', '30de4fd9-b4d5-409e-86a5-09b387f70bfa', '-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line, '-device', 'zpci,uid=7,target=n', '-device', 'virtio-net-pci,id=n,mac=02:ca:fe:fa:ce:12', '-device', 'virtio-rng-ccw,devno=fe.1.9876', '-device', 'virtio-gpu-ccw,devno=fe.2.5432') self.vm.launch() self.wait_for_console_pattern('Entering emergency mode') # Some tests to see whether the CLI options have been considered: self.log.info("Test whether QEMU CLI options have been considered") exec_command_and_wait_for_pattern( self, 'while ! (dmesg | grep enP7p0s0) ; do sleep 1 ; done', 'virtio_net virtio0 enP7p0s0: renamed') exec_command_and_wait_for_pattern( self, 'lspci', '0007:00:00.0 Class 0200: Device 1af4:1000') exec_command_and_wait_for_pattern( self, 'cat /sys/class/net/enP7p0s0/address', '02:ca:fe:fa:ce:12') exec_command_and_wait_for_pattern(self, 'lscss', '0.1.9876') exec_command_and_wait_for_pattern(self, 'lscss', '0.2.5432') exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'processors : 4') exec_command_and_wait_for_pattern(self, 'grep MemTotal /proc/meminfo', 'MemTotal: 499848 kB') exec_command_and_wait_for_pattern(self, 'grep Name /proc/sysinfo', 'Extended Name: Some Guest Name') exec_command_and_wait_for_pattern( self, 'grep UUID /proc/sysinfo', '30de4fd9-b4d5-409e-86a5-09b387f70bfa') # Disable blinking cursor, then write some stuff into the framebuffer. # QEMU's PPM screendumps contain uncompressed 24-bit values, while the # framebuffer uses 32-bit, so we pad our text with some spaces when # writing to the framebuffer. Since the PPM is uncompressed, we then # can simply read the written "magic bytes" back from the PPM file to # check whether the framebuffer is working as expected. self.log.info("Test screendump of virtio-gpu device") exec_command_and_wait_for_pattern( self, 'while ! (dmesg | grep gpudrmfb) ; do sleep 1 ; done', 'virtio_gpudrmfb frame buffer device') exec_command_and_wait_for_pattern(self, 'echo -e "\e[?25l" > /dev/tty0', ':/#') exec_command_and_wait_for_pattern( self, 'for ((i=0;i<250;i++)); do ' 'echo " The qu ick fo x j ump s o ver a laz y d og" >> fox.txt;' 'done', ':/#') exec_command_and_wait_for_pattern( self, 'dd if=fox.txt of=/dev/fb0 bs=1000 oflag=sync,nocache ; rm fox.txt', '12+0 records out') with tempfile.NamedTemporaryFile(suffix='.ppm', prefix='qemu-scrdump-') as ppmfile: self.vm.command('screendump', filename=ppmfile.name) ppmfile.seek(0) line = ppmfile.readline() self.assertEqual(line, b"P6\n") line = ppmfile.readline() self.assertEqual(line, b"1024 768\n") line = ppmfile.readline() self.assertEqual(line, b"255\n") line = ppmfile.readline(256) self.assertEqual(line, b"The quick fox jumps over a lazy dog\n") # Hot-plug a virtio-crypto device and see whether it gets accepted self.log.info("Test hot-plug virtio-crypto device") self.clear_guest_dmesg() self.vm.command('object-add', qom_type='cryptodev-backend-builtin', id='cbe0') self.vm.command('device_add', driver='virtio-crypto-ccw', id='crypdev0', cryptodev='cbe0', devno='fe.0.2342') exec_command_and_wait_for_pattern( self, 'while ! (dmesg -c | grep Accelerator.device) ; do' ' sleep 1 ; done', 'Accelerator device is ready') exec_command_and_wait_for_pattern(self, 'lscss', '0.0.2342') self.vm.command('device_del', id='crypdev0') self.vm.command('object-del', id='cbe0') exec_command_and_wait_for_pattern( self, 'while ! (dmesg -c | grep Start.virtcrypto_remove) ; do' ' sleep 1 ; done', 'Start virtcrypto_remove.')
def test_arm_ast2600_evb_sdk(self): """ :avocado: tags=arch:arm :avocado: tags=machine:ast2600-evb """ image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' 'download/v08.01/ast2600-default-obmc.tar.gz') image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15') image_path = self.fetch_asset(image_url, asset_hash=image_hash, algorithm='sha256') archive.extract(image_path, self.workdir) self.vm.add_args('-device', 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test'); self.vm.add_args('-device', 'ds1338,bus=aspeed.i2c.bus.5,address=0x32'); self.do_test_arm_aspeed_sdk_start( self.workdir + '/ast2600-default/image-bmc', '0xf00') self.wait_for_console_pattern('ast2600-default login:'******'root', 'Password:'******'0penBmc', 'root@ast2600-default:~#') exec_command_and_wait_for_pattern(self, 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device', 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d'); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon19/temp1_input', '0') self.vm.command('qom-set', path='/machine/peripheral/tmp-test', property='temperature', value=18000); exec_command_and_wait_for_pattern(self, 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000') exec_command_and_wait_for_pattern(self, 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device', 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32'); year = time.strftime("%Y") exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
def test_vhost_user_vga_virgl(self): """ :avocado: tags=arch:x86_64 :avocado: tags=device:vhost-user-vga """ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + "console=ttyS0 rdinit=/bin/bash") # FIXME: should check presence of vhost-user-gpu, virgl, memfd etc if not kvm_available(self.arch, self.qemu_bin): self.cancel(KVM_NOT_AVAILABLE) vug = pick_default_vug_bin() if not vug: self.cancel("Could not find vhost-user-gpu") kernel_path = self.fetch_asset(self.KERNEL_URL) initrd_path = self.fetch_asset(self.INITRD_URL) # Create socketpair to connect proxy and remote processes qemu_sock, vug_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) os.set_inheritable(qemu_sock.fileno(), True) os.set_inheritable(vug_sock.fileno(), True) self._vug_log_path = os.path.join(self.vm._test_dir, "vhost-user-gpu.log") self._vug_log_file = open(self._vug_log_path, "wb") print(self._vug_log_path) vugp = subprocess.Popen( [vug, "--virgl", "--fd=%d" % vug_sock.fileno()], stdin=subprocess.DEVNULL, stdout=self._vug_log_file, stderr=subprocess.STDOUT, shell=False, close_fds=False, ) self.vm.set_console() self.vm.add_args("-cpu", "host") self.vm.add_args("-m", "2G") self.vm.add_args("-object", "memory-backend-memfd,id=mem,size=2G") self.vm.add_args("-machine", "pc,memory-backend=mem,accel=kvm") self.vm.add_args("-chardev", "socket,id=vug,fd=%d" % qemu_sock.fileno()) self.vm.add_args("-device", "vhost-user-vga,chardev=vug") self.vm.add_args("-display", "egl-headless") self.vm.add_args( "-kernel", kernel_path, "-initrd", initrd_path, "-append", kernel_command_line, ) self.vm.launch() self.wait_for_console_pattern("as init process") exec_command_and_wait_for_pattern(self, "/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl -edid") self.vm.shutdown() qemu_sock.close() vugp.terminate() vugp.wait()
def clear_guest_dmesg(self): exec_command_and_wait_for_pattern( self, 'dmesg -c > /dev/null; ' 'echo dm_clear\ ' + str(self.dmesg_clear_count), 'dm_clear ' + str(self.dmesg_clear_count)) self.dmesg_clear_count += 1
def test_s390x_devices(self): """ :avocado: tags=arch:s390x :avocado: tags=machine:s390-ccw-virtio """ kernel_url = ('https://snapshot.debian.org/archive/debian/' '20201126T092837Z/dists/buster/main/installer-s390x/' '20190702+deb10u6/images/generic/kernel.debian') kernel_hash = '5821fbee57d6220a067a8b967d24595621aa1eb6' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) initrd_url = ('https://snapshot.debian.org/archive/debian/' '20201126T092837Z/dists/buster/main/installer-s390x/' '20190702+deb10u6/images/generic/initrd.debian') initrd_hash = '81ba09c97bef46e8f4660ac25b4ac0a5be3a94d6' initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0 root=/dev/ram0 BOOT_DEBUG=3') self.vm.add_args('-nographic', '-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line, '-device', 'virtio-net-ccw,devno=fe.1.1111', '-device', 'virtio-rng-ccw,devno=fe.2.0000,max_revision=0', '-device', 'virtio-rng-ccw,devno=fe.3.1234,max_revision=2', '-device', 'zpci,uid=5,target=zzz', '-device', 'virtio-net-pci,id=zzz', '-device', 'zpci,uid=0xa,fid=12,target=serial', '-device', 'virtio-serial-pci,id=serial') self.vm.launch() shell_ready = "sh: can't access tty; job control turned off" self.wait_for_console_pattern(shell_ready) # first debug shell is too early, we need to wait for device detection exec_command_and_wait_for_pattern(self, 'exit', shell_ready) ccw_bus_ids="0.1.1111 0.2.0000 0.3.1234" pci_bus_ids="0005:00:00.0 000a:00:00.0" exec_command_and_wait_for_pattern(self, 'ls /sys/bus/ccw/devices/', ccw_bus_ids) exec_command_and_wait_for_pattern(self, 'ls /sys/bus/pci/devices/', pci_bus_ids) # check that the device at 0.2.0000 is in legacy mode, while the # device at 0.3.1234 has the virtio-1 feature bit set virtio_rng_features="00000000000000000000000000001100" + \ "10000000000000000000000000000000" virtio_rng_features_legacy="00000000000000000000000000001100" + \ "00000000000000000000000000000000" exec_command_and_wait_for_pattern(self, 'cat /sys/bus/ccw/devices/0.2.0000/virtio?/features', virtio_rng_features_legacy) exec_command_and_wait_for_pattern(self, 'cat /sys/bus/ccw/devices/0.3.1234/virtio?/features', virtio_rng_features) # verify that we indeed have virtio-net devices (without having the # virtio-net driver handy) exec_command_and_wait_for_pattern(self, 'cat /sys/bus/ccw/devices/0.1.1111/cutype', '3832/01') exec_command_and_wait_for_pattern(self, 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_vendor', '0x1af4') exec_command_and_wait_for_pattern(self, 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_device', '0x0001') # check fid propagation exec_command_and_wait_for_pattern(self, 'cat /sys/bus/pci/devices/000a\:00\:00.0/function_id', '0x0000000c')
def test_arm_orangepi_uboot_netbsd9(self): """ :avocado: tags=arch:arm :avocado: tags=machine:orangepi-pc """ # This test download a 304MB compressed image and expand it to 1.3GB... deb_url = ('http://snapshot.debian.org/archive/debian/' '20200108T145233Z/pool/main/u/u-boot/' 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb') deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) # We use the common OrangePi PC 'plus' build of U-Boot for our secondary # program loader (SPL). We will then set the path to the more specific # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt, # before to boot NetBSD. uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin' uboot_path = self.extract_from_deb(deb_path, uboot_path) image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/' 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz') image_hash = '2babb29d36d8360adcb39c09e31060945259917a' image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) image_path = os.path.join(self.workdir, 'armv7.img') image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path archive.gzip_uncompress(image_path_gz, image_path) # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc with open(uboot_path, 'rb') as f_in: with open(image_path, 'r+b') as f_out: f_out.seek(8 * 1024) shutil.copyfileobj(f_in, f_out) # Extend image, to avoid that NetBSD thinks the partition # inside the image is larger than device size itself f_out.seek(0, 2) f_out.seek(64 * 1024 * 1024, 1) f_out.write(bytearray([0x00])) self.vm.set_console() self.vm.add_args('-nic', 'user', '-drive', image_drive_args, '-global', 'allwinner-rtc.base-year=2000', '-no-reboot') self.vm.launch() wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') interrupt_interactive_console_until_pattern( self, 'Hit any key to stop autoboot:', 'switch to partitions #0, OK') exec_command_and_wait_for_pattern(self, '', '=>') cmd = 'setenv bootargs root=ld0a' exec_command_and_wait_for_pattern(self, cmd, '=>') cmd = 'setenv kernel netbsd-GENERIC.ub' exec_command_and_wait_for_pattern(self, cmd, '=>') cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb' exec_command_and_wait_for_pattern(self, cmd, '=>') cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; " "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; " "fdt addr ${fdt_addr_r}; " "bootm ${kernel_addr_r} - ${fdt_addr_r}'") exec_command_and_wait_for_pattern(self, cmd, '=>') exec_command_and_wait_for_pattern(self, 'boot', 'Booting kernel from Legacy Image') wait_for_console_pattern(self, 'Starting kernel ...') wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') # Wait for user-space wait_for_console_pattern(self, 'Starting root file system check')
def test_s390x_devices(self): """ :avocado: tags=arch:s390x :avocado: tags=machine:s390-ccw-virtio """ kernel_url = ('https://snapshot.debian.org/archive/debian/' '20201126T092837Z/dists/buster/main/installer-s390x/' '20190702+deb10u6/images/generic/kernel.debian') kernel_hash = '5821fbee57d6220a067a8b967d24595621aa1eb6' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) initrd_url = ('https://snapshot.debian.org/archive/debian/' '20201126T092837Z/dists/buster/main/installer-s390x/' '20190702+deb10u6/images/generic/initrd.debian') initrd_hash = '81ba09c97bef46e8f4660ac25b4ac0a5be3a94d6' initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) self.vm.set_console() kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0 root=/dev/ram0 BOOT_DEBUG=3') self.vm.add_args( '-nographic', '-kernel', kernel_path, '-initrd', initrd_path, '-append', kernel_command_line, '-device', 'virtio-net-ccw,devno=fe.1.1111', '-device', 'virtio-rng-ccw,devno=fe.2.0000,max_revision=0,id=rn1', '-device', 'virtio-rng-ccw,devno=fe.3.1234,max_revision=2,id=rn2', '-device', 'zpci,uid=5,target=zzz', '-device', 'virtio-net-pci,id=zzz', '-device', 'zpci,uid=0xa,fid=12,target=serial', '-device', 'virtio-serial-pci,id=serial', '-device', 'virtio-balloon-ccw') self.vm.launch() shell_ready = "sh: can't access tty; job control turned off" self.wait_for_console_pattern(shell_ready) # first debug shell is too early, we need to wait for device detection exec_command_and_wait_for_pattern(self, 'exit', shell_ready) ccw_bus_ids = "0.1.1111 0.2.0000 0.3.1234" pci_bus_ids = "0005:00:00.0 000a:00:00.0" exec_command_and_wait_for_pattern(self, 'ls /sys/bus/ccw/devices/', ccw_bus_ids) exec_command_and_wait_for_pattern(self, 'ls /sys/bus/pci/devices/', pci_bus_ids) # check that the device at 0.2.0000 is in legacy mode, while the # device at 0.3.1234 has the virtio-1 feature bit set virtio_rng_features="00000000000000000000000000001100" + \ "10000000000000000000000000000000" virtio_rng_features_legacy="00000000000000000000000000001100" + \ "00000000000000000000000000000000" exec_command_and_wait_for_pattern( self, 'cat /sys/bus/ccw/devices/0.2.0000/virtio?/features', virtio_rng_features_legacy) exec_command_and_wait_for_pattern( self, 'cat /sys/bus/ccw/devices/0.3.1234/virtio?/features', virtio_rng_features) # check that /dev/hwrng works - and that it's gone after ejecting exec_command_and_wait_for_pattern( self, 'dd if=/dev/hwrng of=/dev/null bs=1k count=10', '10+0 records out') self.clear_guest_dmesg() self.vm.command('device_del', id='rn1') self.wait_for_crw_reports() self.clear_guest_dmesg() self.vm.command('device_del', id='rn2') self.wait_for_crw_reports() exec_command_and_wait_for_pattern( self, 'dd if=/dev/hwrng of=/dev/null bs=1k count=10', 'dd: /dev/hwrng: No such device') # verify that we indeed have virtio-net devices (without having the # virtio-net driver handy) exec_command_and_wait_for_pattern( self, 'cat /sys/bus/ccw/devices/0.1.1111/cutype', '3832/01') exec_command_and_wait_for_pattern( self, 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_vendor', '0x1af4') exec_command_and_wait_for_pattern( self, 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_device', '0x0001') # check fid propagation exec_command_and_wait_for_pattern( self, 'cat /sys/bus/pci/devices/000a\:00\:00.0/function_id', '0x0000000c') # add another device self.clear_guest_dmesg() self.vm.command('device_add', driver='virtio-net-ccw', devno='fe.0.4711', id='net_4711') self.wait_for_crw_reports() exec_command_and_wait_for_pattern( self, 'for i in 1 2 3 4 5 6 7 ; do ' 'if [ -e /sys/bus/ccw/devices/*4711 ]; then break; fi ;' 'sleep 1 ; done ; ls /sys/bus/ccw/devices/', '0.0.4711') # and detach it again self.clear_guest_dmesg() self.vm.command('device_del', id='net_4711') self.vm.event_wait(name='DEVICE_DELETED', match={'data': { 'device': 'net_4711' }}) self.wait_for_crw_reports() exec_command_and_wait_for_pattern(self, 'ls /sys/bus/ccw/devices/0.0.4711', 'No such file or directory') # test the virtio-balloon device exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', 'MemTotal: 115640 kB') self.vm.command('human-monitor-command', command_line='balloon 96') exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', 'MemTotal: 82872 kB') self.vm.command('human-monitor-command', command_line='balloon 128') exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', 'MemTotal: 115640 kB')