aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2025-02-11 13:27:31 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2025-02-11 13:27:32 -0500
commitf9edf32ea2e18a56de5d92f57e9d10565c822367 (patch)
tree2f8627a8801f914a1772574b10cd28e5f4a2b83d
parentffaf7f0376f8040ce9068d71ae9ae8722505c42e (diff)
parent66a1b4991c32e370a4e0ddabf496aa1563aff286 (diff)
downloadqemu-f9edf32ea2e18a56de5d92f57e9d10565c822367.zip
qemu-f9edf32ea2e18a56de5d92f57e9d10565c822367.tar.gz
qemu-f9edf32ea2e18a56de5d92f57e9d10565c822367.tar.bz2
Merge tag 'pull-request-2025-02-11' of https://gitlab.com/thuth/qemu into staging
* Convert more avocado tests to the functional framework * Add a test for the sam460ex machine * Fix the broken FreeBSD CI job by updating it to the latest version # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmerQmoRHHRodXRoQHJl # ZGhhdC5jb20ACgkQLtnXdP5wLbUTeg/+OKvhapE34jUJTQhDkB0XFbFsdhKx/0Jq # UDL435i49B/x68t4sogZrg1qdYHrwANiTwsH/g0llX31oguENLdidUkvS3PhFbMo # QqxfjdlrLwOia1P3/KlWJ9KbxoXmXccDH+LoANoHzO0NPg21tLNPbUUexaouIAvc # ynvQV/OPS5bQRJCrIFN6PbQ6lyYcTOuJJU7j5Vr6FcqKmg7OH9IBCXHmcyEIFCki # Zh/99+IDQkdWWVVsRSkLEPmXGKI/EasPC2GMTQ0LvztkqFUpycufOaL3Qz06yqMP # ZxfshsKfOGCMOMClePICPrck4uvhuMoeXszrjsCWArOYzumuN5al4MtXLJZLWs92 # p+nk0XGQmxjdCHj2ip/lasdjwPd2L1pk4+MXHBUgrmwgDo6EUW55DJd/E8ORsEY9 # yvV4CCL3nCX2PRO1eUgo5FPhQbwF2TgLQO6ut69yRsVzcXh2w/Thzc++eH/qhCYI # fbZUoIySfCcNLzDK/E5H3YVSQHvkc8cE3ymkb1BAOepVkdadc2l0P0D4RmO0/Nxk # vy30Ik5+bf6xsJjpiYFQi8NwGNUwZlDPqlWikVWotlOhobmOqVIlnCovQ06mnru3 # wsneISRLctPMHjlU6u1iuDiO0LG1CUvXrbP01mDwgGXaYAWg7o2e7rlbrExDHzwu # fRs2aYnR9oY= # =K10z # -----END PGP SIGNATURE----- # gpg: Signature made Tue 11 Feb 2025 07:28:26 EST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full] # gpg: aka "Thomas Huth <thuth@redhat.com>" [full] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2025-02-11' of https://gitlab.com/thuth/qemu: gitlab-ci.d/cirrus: Update the FreeBSD job to v14.2 gitlab: use new(ish) cirrus-vars command for creating config gitlab: don't fail cirrus CI jobs when credits are exhausted tests/functional: Add a ppc sam460ex test tests/functional: Convert the hotplug_blk avocado test tests/functional/test_aarch64_virt: Fix vulkan test without egl-headless tests/functional: Convert the aarch64 xen test to the functional framework Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--.gitlab-ci.d/cirrus.yml27
-rw-r--r--.gitlab-ci.d/cirrus/build.yml2
-rw-r--r--MAINTAINERS4
-rw-r--r--tests/avocado/boot_xen.py95
-rw-r--r--tests/avocado/hotplug_blk.py69
-rw-r--r--tests/functional/meson.build3
-rwxr-xr-xtests/functional/test_aarch64_virt.py2
-rwxr-xr-xtests/functional/test_aarch64_xen.py90
-rw-r--r--tests/functional/test_ppc_sam460ex.py38
-rwxr-xr-xtests/functional/test_x86_64_hotplug_blk.py85
10 files changed, 228 insertions, 187 deletions
diff --git a/.gitlab-ci.d/cirrus.yml b/.gitlab-ci.d/cirrus.yml
index a9e43e2..75b6114 100644
--- a/.gitlab-ci.d/cirrus.yml
+++ b/.gitlab-ci.d/cirrus.yml
@@ -15,32 +15,17 @@
stage: build
image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:latest
needs: []
+ allow_failure:
+ exit_codes: 3
# 20 mins larger than "timeout_in" in cirrus/build.yml
# as there's often a 5-10 minute delay before Cirrus CI
# actually starts the task
timeout: 80m
script:
+ - set -o allexport
- source .gitlab-ci.d/cirrus/$NAME.vars
- - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g"
- -e "s|[@]CI_COMMIT_REF_NAME@|$CI_COMMIT_REF_NAME|g"
- -e "s|[@]CI_COMMIT_SHA@|$CI_COMMIT_SHA|g"
- -e "s|[@]CIRRUS_VM_INSTANCE_TYPE@|$CIRRUS_VM_INSTANCE_TYPE|g"
- -e "s|[@]CIRRUS_VM_IMAGE_SELECTOR@|$CIRRUS_VM_IMAGE_SELECTOR|g"
- -e "s|[@]CIRRUS_VM_IMAGE_NAME@|$CIRRUS_VM_IMAGE_NAME|g"
- -e "s|[@]CIRRUS_VM_CPUS@|$CIRRUS_VM_CPUS|g"
- -e "s|[@]CIRRUS_VM_RAM@|$CIRRUS_VM_RAM|g"
- -e "s|[@]UPDATE_COMMAND@|$UPDATE_COMMAND|g"
- -e "s|[@]INSTALL_COMMAND@|$INSTALL_COMMAND|g"
- -e "s|[@]PATH@|$PATH_EXTRA${PATH_EXTRA:+:}\$PATH|g"
- -e "s|[@]PKG_CONFIG_PATH@|$PKG_CONFIG_PATH|g"
- -e "s|[@]PKGS@|$PKGS|g"
- -e "s|[@]MAKE@|$MAKE|g"
- -e "s|[@]PYTHON@|$PYTHON|g"
- -e "s|[@]PIP3@|$PIP3|g"
- -e "s|[@]PYPI_PKGS@|$PYPI_PKGS|g"
- -e "s|[@]CONFIGURE_ARGS@|$CONFIGURE_ARGS|g"
- -e "s|[@]TEST_TARGETS@|$TEST_TARGETS|g"
- <.gitlab-ci.d/cirrus/build.yml >.gitlab-ci.d/cirrus/$NAME.yml
+ - set +o allexport
+ - cirrus-vars <.gitlab-ci.d/cirrus/build.yml >.gitlab-ci.d/cirrus/$NAME.yml
- cat .gitlab-ci.d/cirrus/$NAME.yml
- cirrus-run -v --show-build-log always .gitlab-ci.d/cirrus/$NAME.yml
variables:
@@ -52,7 +37,7 @@ x64-freebsd-14-build:
NAME: freebsd-14
CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
CIRRUS_VM_IMAGE_SELECTOR: image_family
- CIRRUS_VM_IMAGE_NAME: freebsd-14-1
+ CIRRUS_VM_IMAGE_NAME: freebsd-14-2
CIRRUS_VM_CPUS: 8
CIRRUS_VM_RAM: 8G
UPDATE_COMMAND: pkg update; pkg upgrade -y
diff --git a/.gitlab-ci.d/cirrus/build.yml b/.gitlab-ci.d/cirrus/build.yml
index 102cdbd..41abd0b 100644
--- a/.gitlab-ci.d/cirrus/build.yml
+++ b/.gitlab-ci.d/cirrus/build.yml
@@ -8,7 +8,7 @@ env:
CI_REPOSITORY_URL: "@CI_REPOSITORY_URL@"
CI_COMMIT_REF_NAME: "@CI_COMMIT_REF_NAME@"
CI_COMMIT_SHA: "@CI_COMMIT_SHA@"
- PATH: "@PATH@"
+ PATH: "@PATH_EXTRA@:$PATH"
PKG_CONFIG_PATH: "@PKG_CONFIG_PATH@"
PYTHON: "@PYTHON@"
MAKE: "@MAKE@"
diff --git a/MAINTAINERS b/MAINTAINERS
index 842bac8..3848d37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1562,6 +1562,7 @@ F: pc-bios/canyonlands.dt[sb]
F: pc-bios/u-boot-sam460ex-20100605.bin
F: roms/u-boot-sam460ex
F: docs/system/ppc/amigang.rst
+F: tests/functional/test_ppc_sam460ex.py
pegasos2
M: BALATON Zoltan <balaton@eik.bme.hu>
@@ -2275,6 +2276,7 @@ F: hw/block/virtio-blk.c
F: hw/block/dataplane/*
F: include/hw/virtio/virtio-blk-common.h
F: tests/qtest/virtio-blk-test.c
+F: tests/functional/test_x86_64_hotplug_blk.py
T: git https://github.com/stefanha/qemu.git block
virtio-ccw
@@ -2539,7 +2541,7 @@ M: Alex Bennée <alex.bennee@linaro.org>
S: Maintained
F: hw/core/guest-loader.c
F: docs/system/guest-loader.rst
-F: tests/avocado/boot_xen.py
+F: tests/functional/test_aarch64_xen.py
Intel Hexadecimal Object File Loader
M: Su Hang <suhang16@mails.ucas.ac.cn>
diff --git a/tests/avocado/boot_xen.py b/tests/avocado/boot_xen.py
deleted file mode 100644
index 490a127..0000000
--- a/tests/avocado/boot_xen.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Functional test that boots a Xen hypervisor with a domU kernel and
-# checks the console output is vaguely sane .
-#
-# Copyright (c) 2020 Linaro
-#
-# Author:
-# Alex Bennée <alex.bennee@linaro.org>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# This work is licensed under the terms of the GNU GPL, version 2 or
-# later. See the COPYING file in the top-level directory.
-
-import os
-
-from avocado_qemu import wait_for_console_pattern
-from boot_linux_console import LinuxKernelTest
-
-
-class BootXen(LinuxKernelTest):
- """
- Boots a Xen hypervisor with a Linux DomU kernel.
-
- :avocado: tags=arch:aarch64
- :avocado: tags=accel:tcg
- :avocado: tags=cpu:cortex-a57
- :avocado: tags=machine:virt
- """
-
- timeout = 90
- XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
-
- def setUp(self):
- super(BootXen, self).setUp()
-
- # Using my own built kernel - which works
- kernel_url = ('https://fileserver.linaro.org/'
- 's/JSsewXGZ6mqxPr5/download?path=%2F&files='
- 'linux-5.9.9-arm64-ajb')
- kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
- self.kernel_path = self.fetch_asset(kernel_url,
- asset_hash=kernel_sha1)
-
- def launch_xen(self, xen_path):
- """
- Launch Xen with a dom0 guest kernel
- """
- self.log.info("launch with xen_path: %s", xen_path)
-
- self.vm.set_console()
-
- self.vm.add_args('-machine', 'virtualization=on',
- '-m', '768',
- '-kernel', xen_path,
- '-append', self.XEN_COMMON_COMMAND_LINE,
- '-device',
- 'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
- % (self.kernel_path))
-
- self.vm.launch()
-
- console_pattern = 'VFS: Cannot open root device'
- wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
-
- def test_arm64_xen_411_and_dom0(self):
- # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
- xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
- 'download?path=%2F&files='
- 'xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb')
- xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
- xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
- xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
-
- self.launch_xen(xen_path)
-
- def test_arm64_xen_414_and_dom0(self):
- # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
- xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
- 'download?path=%2F&files='
- 'xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb')
- xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
- xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
- xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
-
- self.launch_xen(xen_path)
-
- def test_arm64_xen_415_and_dom0(self):
- xen_url = ('https://fileserver.linaro.org/'
- 's/JSsewXGZ6mqxPr5/download'
- '?path=%2F&files=xen-upstream-4.15-unstable.deb')
- xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
- xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
- xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
-
- self.launch_xen(xen_path)
diff --git a/tests/avocado/hotplug_blk.py b/tests/avocado/hotplug_blk.py
deleted file mode 100644
index b36bca0..0000000
--- a/tests/avocado/hotplug_blk.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# Functional test that hotplugs a virtio blk disk and checks it on a Linux
-# guest
-#
-# Copyright (c) 2021 Red Hat, Inc.
-# Copyright (c) Yandex
-#
-# This work is licensed under the terms of the GNU GPL, version 2 or
-# later. See the COPYING file in the top-level directory.
-
-import time
-
-from avocado_qemu.linuxtest import LinuxTest
-
-
-class HotPlug(LinuxTest):
- def blockdev_add(self) -> None:
- self.vm.cmd('blockdev-add', **{
- 'driver': 'null-co',
- 'size': 1073741824,
- 'node-name': 'disk'
- })
-
- def assert_vda(self) -> None:
- self.ssh_command('test -e /sys/block/vda')
-
- def assert_no_vda(self) -> None:
- with self.assertRaises(AssertionError):
- self.assert_vda()
-
- def plug(self) -> None:
- args = {
- 'driver': 'virtio-blk-pci',
- 'drive': 'disk',
- 'id': 'virtio-disk0',
- 'bus': 'pci.1',
- 'addr': '1',
- }
-
- self.assert_no_vda()
- self.vm.cmd('device_add', args)
- try:
- self.assert_vda()
- except AssertionError:
- time.sleep(1)
- self.assert_vda()
-
- def unplug(self) -> None:
- self.vm.cmd('device_del', id='virtio-disk0')
-
- self.vm.event_wait('DEVICE_DELETED', 1.0,
- match={'data': {'device': 'virtio-disk0'}})
-
- self.assert_no_vda()
-
- def test(self) -> None:
- """
- :avocado: tags=arch:x86_64
- :avocado: tags=machine:q35
- :avocado: tags=accel:kvm
- """
- self.require_accelerator('kvm')
- self.vm.add_args('-accel', 'kvm')
- self.vm.add_args('-device', 'pcie-pci-bridge,id=pci.1,bus=pcie.0')
-
- self.launch_and_wait()
- self.blockdev_add()
-
- self.plug()
- self.unplug()
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 3f085bf..b516d21 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -77,6 +77,7 @@ tests_aarch64_system_thorough = [
'aarch64_tcg_plugins',
'aarch64_tuxrun',
'aarch64_virt',
+ 'aarch64_xen',
'aarch64_xlnx_versal',
'multiprocess',
]
@@ -196,6 +197,7 @@ tests_ppc_system_thorough = [
'ppc_bamboo',
'ppc_mac',
'ppc_mpc8544ds',
+ 'ppc_sam460ex',
'ppc_tuxrun',
'ppc_virtex_ml507',
]
@@ -284,6 +286,7 @@ tests_x86_64_system_thorough = [
'multiprocess',
'netdev_ethtool',
'virtio_gpu',
+ 'x86_64_hotplug_blk',
'x86_64_hotplug_cpu',
'x86_64_kvm_xen',
'x86_64_tuxrun',
diff --git a/tests/functional/test_aarch64_virt.py b/tests/functional/test_aarch64_virt.py
index 07c1c13..95f5ce8 100755
--- a/tests/functional/test_aarch64_virt.py
+++ b/tests/functional/test_aarch64_virt.py
@@ -189,6 +189,8 @@ class Aarch64VirtMachine(QemuSystemTest):
self.skipTest("No venus support for virtio-gpu")
elif "egl: no drm render node available" in excp.output:
self.skipTest("Can't access host DRM render node")
+ elif "'type' does not accept value 'egl-headless'" in excp.output:
+ self.skipTest("egl-headless support is not available")
else:
self.log.info(f"unhandled launch failure: {excp.output}")
raise excp
diff --git a/tests/functional/test_aarch64_xen.py b/tests/functional/test_aarch64_xen.py
new file mode 100755
index 0000000..3399042
--- /dev/null
+++ b/tests/functional/test_aarch64_xen.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Xen hypervisor with a domU kernel and
+# checks the console output is vaguely sane .
+#
+# Copyright (c) 2020 Linaro
+#
+# Author:
+# Alex Bennée <alex.bennee@linaro.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+from qemu_test import Asset, LinuxKernelTest, wait_for_console_pattern
+
+
+class BootXen(LinuxKernelTest):
+ """
+ Boots a Xen hypervisor with a Linux DomU kernel.
+ """
+
+ timeout = 90
+ XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
+
+ ASSET_KERNEL = Asset(
+ ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/'
+ 'download?path=%2F&files=linux-5.9.9-arm64-ajb'),
+ '00366fa51ea957c19462d2e2aefd480bef80ce727120e714ae48e0c88f261edb')
+
+ def launch_xen(self, xen_path):
+ """
+ Launch Xen with a dom0 guest kernel
+ """
+ self.set_machine('virt')
+ self.cpu = "cortex-a57"
+ self.kernel_path = self.ASSET_KERNEL.fetch()
+ self.log.info("launch with xen_path: %s", xen_path)
+
+ self.vm.set_console()
+
+ self.vm.add_args('-machine', 'virtualization=on',
+ '-m', '768',
+ '-kernel', xen_path,
+ '-append', self.XEN_COMMON_COMMAND_LINE,
+ '-device',
+ 'guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0'
+ % (self.kernel_path))
+
+ self.vm.launch()
+
+ console_pattern = 'VFS: Cannot open root device'
+ wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
+
+ ASSET_XEN_4_11 = Asset(
+ ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
+ 'files=xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb'),
+ 'b745c2631342f9fcc0147ddc364edb62c20ecfebd430e5a3546e7d7c6891c0bc')
+
+ def test_arm64_xen_411_and_dom0(self):
+ # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
+ xen_path = self.archive_extract(self.ASSET_XEN_4_11, format='deb',
+ member="boot/xen-4.11-arm64")
+ self.launch_xen(xen_path)
+
+ ASSET_XEN_4_14 = Asset(
+ ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
+ 'files=xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb'),
+ 'e930a3293248edabd367d5b4b3b6448b9c99c057096ea8b47228a7870661d5cb')
+
+ def test_arm64_xen_414_and_dom0(self):
+ # archive of file from https://deb.debian.org/debian/pool/main/x/xen/
+ xen_path = self.archive_extract(self.ASSET_XEN_4_14, format='deb',
+ member="boot/xen-4.14-arm64")
+ self.launch_xen(xen_path)
+
+ ASSET_XEN_4_15 = Asset(
+ ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/download?path=%2F&'
+ 'files=xen-upstream-4.15-unstable.deb'),
+ '2a9a8af8acf0231844657cc28baab95bd918b0ee2d493ee4ee6f8846e1358bc9')
+
+ def test_arm64_xen_415_and_dom0(self):
+ xen_path = self.archive_extract(self.ASSET_XEN_4_15, format='deb',
+ member="boot/xen-4.15-unstable")
+ self.launch_xen(xen_path)
+
+
+if __name__ == '__main__':
+ LinuxKernelTest.main()
diff --git a/tests/functional/test_ppc_sam460ex.py b/tests/functional/test_ppc_sam460ex.py
new file mode 100644
index 0000000..31cf9dd
--- /dev/null
+++ b/tests/functional/test_ppc_sam460ex.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a sam460ex machine with a PPC 460EX CPU
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+from qemu_test import exec_command_and_wait_for_pattern
+
+
+class sam460exTest(LinuxKernelTest):
+
+ ASSET_BR2_SAM460EX_LINUX = Asset(
+ 'https://github.com/legoater/qemu-ppc-boot/raw/refs/heads/main/buildroot/qemu_ppc_sam460ex-2023.11-8-gdcd9f0f6eb-20240105/vmlinux',
+ '6f46346f3e20e8b5fc050ff363f350f8b9d76a051b9e0bd7ea470cc680c14df2')
+
+ def test_ppc_sam460ex_buildroot(self):
+ self.set_machine('sam460ex')
+ self.require_netdev('user')
+
+ linux_path = self.ASSET_BR2_SAM460EX_LINUX.fetch()
+
+ self.vm.set_console()
+ self.vm.add_args('-kernel', linux_path,
+ '-device', 'virtio-net-pci,netdev=net0',
+ '-netdev', 'user,id=net0')
+ self.vm.launch()
+
+ self.wait_for_console_pattern('Linux version')
+ self.wait_for_console_pattern('Hardware name: amcc,canyonlands 460EX')
+ self.wait_for_console_pattern('/init as init process')
+ self.wait_for_console_pattern('lease of 10.0.2.15 obtained')
+ self.wait_for_console_pattern('buildroot login:')
+ exec_command_and_wait_for_pattern(self, 'root', '#')
+ exec_command_and_wait_for_pattern(self, 'poweroff', 'System Halted')
+
+if __name__ == '__main__':
+ LinuxKernelTest.main()
diff --git a/tests/functional/test_x86_64_hotplug_blk.py b/tests/functional/test_x86_64_hotplug_blk.py
new file mode 100755
index 0000000..7ddbfef
--- /dev/null
+++ b/tests/functional/test_x86_64_hotplug_blk.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+#
+# Functional test that hotplugs a virtio blk disk and checks it on a Linux
+# guest
+#
+# Copyright (c) 2021 Red Hat, Inc.
+# Copyright (c) Yandex
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
+
+
+class HotPlugBlk(LinuxKernelTest):
+
+ ASSET_KERNEL = Asset(
+ ('https://archives.fedoraproject.org/pub/archive/fedora/linux/releases'
+ '/31/Server/x86_64/os/images/pxeboot/vmlinuz'),
+ 'd4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129')
+
+ ASSET_INITRD = Asset(
+ ('https://archives.fedoraproject.org/pub/archive/fedora/linux/releases'
+ '/31/Server/x86_64/os/images/pxeboot/initrd.img'),
+ '277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b')
+
+ def blockdev_add(self) -> None:
+ self.vm.cmd('blockdev-add', **{
+ 'driver': 'null-co',
+ 'size': 1073741824,
+ 'node-name': 'disk'
+ })
+
+ def assert_vda(self) -> None:
+ exec_command_and_wait_for_pattern(self, 'while ! test -e /sys/block/vda ;'
+ ' do sleep 0.2 ; done', '# ')
+
+ def assert_no_vda(self) -> None:
+ exec_command_and_wait_for_pattern(self, 'while test -e /sys/block/vda ;'
+ ' do sleep 0.2 ; done', '# ')
+
+ def plug(self) -> None:
+ args = {
+ 'driver': 'virtio-blk-pci',
+ 'drive': 'disk',
+ 'id': 'virtio-disk0',
+ 'bus': 'pci.1',
+ 'addr': '1',
+ }
+
+ self.assert_no_vda()
+ self.vm.cmd('device_add', args)
+ self.wait_for_console_pattern('virtio_blk virtio0: [vda]')
+ self.assert_vda()
+
+ def unplug(self) -> None:
+ self.vm.cmd('device_del', id='virtio-disk0')
+
+ self.vm.event_wait('DEVICE_DELETED', 1.0,
+ match={'data': {'device': 'virtio-disk0'}})
+
+ self.assert_no_vda()
+
+ def test(self) -> None:
+ self.require_accelerator('kvm')
+ self.set_machine('q35')
+
+ self.vm.add_args('-accel', 'kvm')
+ self.vm.add_args('-device', 'pcie-pci-bridge,id=pci.1,bus=pcie.0')
+ self.vm.add_args('-m', '1G')
+ self.vm.add_args('-append', 'console=ttyS0 rd.rescue')
+
+ self.launch_kernel(self.ASSET_KERNEL.fetch(),
+ self.ASSET_INITRD.fetch(),
+ wait_for='Entering emergency mode.')
+ self.wait_for_console_pattern('# ')
+
+ self.blockdev_add()
+
+ self.plug()
+ self.unplug()
+
+
+if __name__ == '__main__':
+ LinuxKernelTest.main()