qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests/avocado: add hotplug_blk test
@ 2024-04-09  6:58 Vladimir Sementsov-Ogievskiy
  2024-04-24 18:16 ` Vladimir Sementsov-Ogievskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-04-09  6:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, crosa, philmd, wainersm, bleal, vsementsov, yc-core

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>
---
 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.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tests/avocado: add hotplug_blk test
  2024-04-09  6:58 [PATCH] tests/avocado: add hotplug_blk test Vladimir Sementsov-Ogievskiy
@ 2024-04-24 18:16 ` Vladimir Sementsov-Ogievskiy
  2024-06-25 14:29 ` Vladimir Sementsov-Ogievskiy
  2024-06-26  7:24 ` Thomas Huth
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-04-24 18:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, crosa, philmd, wainersm, bleal, yc-core

ping!)

-- 
Best regards,
Vladimir



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tests/avocado: add hotplug_blk test
  2024-04-09  6:58 [PATCH] tests/avocado: add hotplug_blk test Vladimir Sementsov-Ogievskiy
  2024-04-24 18:16 ` Vladimir Sementsov-Ogievskiy
@ 2024-06-25 14:29 ` Vladimir Sementsov-Ogievskiy
  2024-06-26  7:24 ` Thomas Huth
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-06-25 14:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, crosa, philmd, wainersm, bleal, yc-core

ping2

On 09.04.24 09:58, Vladimir Sementsov-Ogievskiy wrote:
> 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>

-- 
Best regards,
Vladimir



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tests/avocado: add hotplug_blk test
  2024-04-09  6:58 [PATCH] tests/avocado: add hotplug_blk test Vladimir Sementsov-Ogievskiy
  2024-04-24 18:16 ` Vladimir Sementsov-Ogievskiy
  2024-06-25 14:29 ` Vladimir Sementsov-Ogievskiy
@ 2024-06-26  7:24 ` Thomas Huth
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2024-06-26  7:24 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, qemu-devel
  Cc: qemu-block, crosa, philmd, wainersm, bleal, yc-core

On 09/04/2024 08.58, Vladimir Sementsov-Ogievskiy wrote:
> 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>
> ---
>   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()

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-26  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09  6:58 [PATCH] tests/avocado: add hotplug_blk test Vladimir Sementsov-Ogievskiy
2024-04-24 18:16 ` Vladimir Sementsov-Ogievskiy
2024-06-25 14:29 ` Vladimir Sementsov-Ogievskiy
2024-06-26  7:24 ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).