* [PATCH] iotests: add test for changing the 'drive' property via 'qom-set'
@ 2025-06-05 10:09 Fiona Ebner
2025-07-14 16:04 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2025-06-05 10:09 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, kwolf, hreitz
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
tests/qemu-iotests/tests/qom-set-drive | 75 ++++++++++++++++++++++
tests/qemu-iotests/tests/qom-set-drive.out | 11 ++++
2 files changed, 86 insertions(+)
create mode 100755 tests/qemu-iotests/tests/qom-set-drive
create mode 100644 tests/qemu-iotests/tests/qom-set-drive.out
diff --git a/tests/qemu-iotests/tests/qom-set-drive b/tests/qemu-iotests/tests/qom-set-drive
new file mode 100755
index 0000000000..e44fe4cebc
--- /dev/null
+++ b/tests/qemu-iotests/tests/qom-set-drive
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# group: quick
+#
+# Test how changing the 'drive' property via 'qom-set' behaves.
+#
+# Copyright (C) Proxmox Server Solutions GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import iotests
+from iotests import imgfmt, log, qemu_img_create, QMPTestCase
+
+image_size = 1 * 1024 * 1024
+images = [os.path.join(iotests.test_dir, f'{i}.img') for i in range(0, 4)]
+
+class TestQOMSetDrive(QMPTestCase):
+ def setUp(self) -> None:
+ for i in range(0, len(images)):
+ qemu_img_create('-f', imgfmt, images[i], str(image_size))
+
+ self.vm = iotests.VM()
+ for i in range(0, len(images)):
+ self.vm.add_blockdev(self.vm.qmp_to_opts({
+ 'driver': imgfmt,
+ 'node-name': f'node{i}',
+ 'file': {
+ 'driver': 'file',
+ 'filename': images[i]
+ }
+ }))
+ self.vm.add_object('iothread,id=iothread0')
+ self.vm.add_device('virtio-scsi,iothread=iothread0')
+ self.vm.add_device(f'scsi-hd,id=iot,drive=node0')
+ self.vm.add_device('virtio-scsi')
+ self.vm.add_device(f'scsi-hd,id=no-iot,drive=node1')
+ self.vm.launch()
+
+ def tearDown(self) -> None:
+ self.vm.shutdown()
+ for i in range(0, len(images)):
+ os.remove(images[i])
+
+ def test_qom_set_drive(self) -> None:
+ log(self.vm.qmp('qom-get', path='/machine/peripheral/iot',
+ property='drive'))
+ log(self.vm.qmp('qom-set', path='/machine/peripheral/iot',
+ property='drive', value='node2'))
+ log(self.vm.qmp('qom-get', path='/machine/peripheral/iot',
+ property='drive'))
+
+ log(self.vm.qmp('qom-get', path='/machine/peripheral/no-iot',
+ property='drive'))
+ log(self.vm.qmp('qom-set', path='/machine/peripheral/no-iot',
+ property='drive', value='node3'))
+ log(self.vm.qmp('qom-get', path='/machine/peripheral/no-iot',
+ property='drive'))
+
+if __name__ == '__main__':
+ iotests.activate_logging()
+ # LUKS would require special key-secret handling in add_blockdevs()
+ iotests.main(supported_fmts=['generic'],
+ unsupported_fmts=['luks'])
diff --git a/tests/qemu-iotests/tests/qom-set-drive.out b/tests/qemu-iotests/tests/qom-set-drive.out
new file mode 100644
index 0000000000..7fc243dca6
--- /dev/null
+++ b/tests/qemu-iotests/tests/qom-set-drive.out
@@ -0,0 +1,11 @@
+{"return": "node0"}
+{"error": {"class": "GenericError", "desc": "Different aio context is not supported for new node"}}
+{"return": "node0"}
+{"return": "node1"}
+{"return": {}}
+{"return": "node3"}
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iotests: add test for changing the 'drive' property via 'qom-set'
2025-06-05 10:09 [PATCH] iotests: add test for changing the 'drive' property via 'qom-set' Fiona Ebner
@ 2025-07-14 16:04 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2025-07-14 16:04 UTC (permalink / raw)
To: Fiona Ebner; +Cc: qemu-block, qemu-devel, hreitz
Am 05.06.2025 um 12:09 hat Fiona Ebner geschrieben:
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-14 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 10:09 [PATCH] iotests: add test for changing the 'drive' property via 'qom-set' Fiona Ebner
2025-07-14 16:04 ` Kevin Wolf
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).