From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PULL 3/7] tests/functional: Convert the hotplug_blk avocado test
Date: Tue, 11 Feb 2025 13:31:40 +0100 [thread overview]
Message-ID: <20250211123144.37617-4-thuth@redhat.com> (raw)
In-Reply-To: <20250211123144.37617-1-thuth@redhat.com>
By using the serial console instead of ssh for executing commands
in the guest, we can convert this test to the functional framework.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250130192712.19542-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
MAINTAINERS | 1 +
tests/avocado/hotplug_blk.py | 69 -----------------
tests/functional/meson.build | 1 +
tests/functional/test_x86_64_hotplug_blk.py | 85 +++++++++++++++++++++
4 files changed, 87 insertions(+), 69 deletions(-)
delete mode 100644 tests/avocado/hotplug_blk.py
create mode 100755 tests/functional/test_x86_64_hotplug_blk.py
diff --git a/MAINTAINERS b/MAINTAINERS
index ebb415bc40..a593241800 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2275,6 +2275,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
diff --git a/tests/avocado/hotplug_blk.py b/tests/avocado/hotplug_blk.py
deleted file mode 100644
index b36bca02ec..0000000000
--- 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 e595508bfa..70646d3457 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -285,6 +285,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_x86_64_hotplug_blk.py b/tests/functional/test_x86_64_hotplug_blk.py
new file mode 100755
index 0000000000..7ddbfefc21
--- /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()
--
2.48.1
next prev parent reply other threads:[~2025-02-11 12:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 12:31 [PULL 0/7] Functional tests and Gitlab-CI patches Thomas Huth
2025-02-11 12:31 ` [PULL 1/7] tests/functional: Convert the aarch64 xen test to the functional framework Thomas Huth
2025-02-11 12:31 ` [PULL 2/7] tests/functional/test_aarch64_virt: Fix vulkan test without egl-headless Thomas Huth
2025-02-11 12:31 ` Thomas Huth [this message]
2025-02-11 12:31 ` [PULL 4/7] tests/functional: Add a ppc sam460ex test Thomas Huth
2025-02-11 14:38 ` BALATON Zoltan
2025-02-11 12:31 ` [PULL 5/7] gitlab: don't fail cirrus CI jobs when credits are exhausted Thomas Huth
2025-02-11 12:31 ` [PULL 6/7] gitlab: use new(ish) cirrus-vars command for creating config Thomas Huth
2025-02-11 12:31 ` [PULL 7/7] gitlab-ci.d/cirrus: Update the FreeBSD job to v14.2 Thomas Huth
2025-02-12 13:45 ` [PULL 0/7] Functional tests and Gitlab-CI patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250211123144.37617-4-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.