From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Subject: [PULL 10/12] tests/avocado: add hotplug_blk test
Date: Tue, 2 Jul 2024 12:33:08 +0200 [thread overview]
Message-ID: <20240702103310.347201-11-thuth@redhat.com> (raw)
In-Reply-To: <20240702103310.347201-1-thuth@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Introduce a test, that checks that plug/unplug of virtio-blk device
works.
(the test is developed by copying hotplug_cpu.py, so keep original
copyright)
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20240409065854.366856-1-vsementsov@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/avocado/hotplug_blk.py | 69 ++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 tests/avocado/hotplug_blk.py
diff --git a/tests/avocado/hotplug_blk.py b/tests/avocado/hotplug_blk.py
new file mode 100644
index 0000000000..5dc30f6616
--- /dev/null
+++ b/tests/avocado/hotplug_blk.py
@@ -0,0 +1,69 @@
+# 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 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()
--
2.45.2
next prev parent reply other threads:[~2024-07-02 10:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 10:32 [PULL 00/12] qtest, s390x, avocado and doc patches Thomas Huth
2024-07-02 10:32 ` [PULL 01/12] hw/intc/s390_flic: Fix interrupt controller migration on s390x with TCG Thomas Huth
2024-07-02 10:33 ` [PULL 02/12] tests/qtest/migration-test: enable " Thomas Huth
2024-07-04 11:20 ` Nicholas Piggin
2024-07-04 11:48 ` Thomas Huth
2024-07-05 0:11 ` Nicholas Piggin
2024-07-02 10:33 ` [PULL 03/12] tests/qtest: Use qtest_add_data_func_full() Thomas Huth
2024-07-02 10:33 ` [PULL 04/12] tests/qtest: Free unused QMP response Thomas Huth
2024-07-02 10:33 ` [PULL 05/12] tests/qtest: Free old machine variable name Thomas Huth
2024-07-02 10:33 ` [PULL 06/12] tests/qtest: Free paths Thomas Huth
2024-07-02 10:33 ` [PULL 07/12] tests/qtest: Free GThread Thomas Huth
2024-07-02 10:33 ` [PULL 08/12] docs: add precision about capstone for execlog plugin Thomas Huth
2024-07-02 10:33 ` [PULL 09/12] hw/s390x: Attach default virtio-net devices to the /machine/virtual-css-bridge Thomas Huth
2024-07-02 10:33 ` Thomas Huth [this message]
2024-07-02 10:33 ` [PULL 11/12] .travis.yml: Install python3-tomli in all build jobs Thomas Huth
2024-07-02 10:33 ` [PULL 12/12] pc-bios/s390-ccw: Remove duplicated LDFLAGS Thomas Huth
2024-07-03 4:46 ` [PULL 00/12] qtest, s390x, avocado and doc patches Richard Henderson
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=20240702103310.347201-11-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=vsementsov@yandex-team.ru \
/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.