From 43419f41bf42980dd0da82017bc0c82a470727df Mon Sep 17 00:00:00 2001 From: "Houqi (Nick) Zuo" Date: Wed, 16 Apr 2025 21:11:49 +0800 Subject: [PATCH] [Draft] Test only Signed-off-by: Houqi (Nick) Zuo --- qemu/tests/cfg/multi_targets.cfg | 39 ++++++++++++++++++++++++++++++++ qemu/tests/multi_targets.py | 36 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 qemu/tests/cfg/multi_targets.cfg create mode 100644 qemu/tests/multi_targets.py diff --git a/qemu/tests/cfg/multi_targets.cfg b/qemu/tests/cfg/multi_targets.cfg new file mode 100644 index 0000000000..43754af17e --- /dev/null +++ b/qemu/tests/cfg/multi_targets.cfg @@ -0,0 +1,39 @@ +- multi_targets: + virt_test_type = qemu + type = multi_targets + start_vm = yes + kill_vm = yes + kill_vm_gracefully = yes + shutdown_cleanly = no + reboot_method = shell + not_preprocess = yes + data_images="stg1" + images += " ${data_images}" + drive_werror = stop + drive_rerror = stop + force_create_image_stg1 = yes + force_remove_image_stg1 = yes + + iscsi_target_backstores = bs1 bs2 + # "backend", "emulated_image", "emulated_image_size" are mandatory + # "attrs" is optional + iscsi_target_backstore_options_bs1 = '{"backend": "fileio","emulated_image": "images/basefile001","emulated_image_size": "90M","attrs": "block_size=4096",}' + iscsi_target_backstore_options_bs2 = '{"backend": "fileio","emulated_image": "images/basefile002","emulated_image_size": "50M",}' + # mandatory + iscsi_targets = t1 t2 t3 t4 + # "portal_ip", "attrs", "binding_basckstores" are optional + iscsi_target_options_t1 = '{"portal_ip": ["127.0.0.1"],' + iscsi_target_options_t1 += '"attrs": "authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1",' + iscsi_target_options_t1 += '"binding_basckstores": ["bs1"],' + iscsi_target_options_t1 += '"name": "iqn.2025-05.com.test:test01",}' + iscsi_target_options_t2 = '{"portal_ip": ["127.0.0.1"],' + iscsi_target_options_t2 += '"binding_basckstores" : ["bs2"],' + iscsi_target_options_t2 += '"name": "iqn.2025-05.com.test:test02",}' + iscsi_target_options_t3 = '{"portal_ip": ["127.0.0.1"],' + iscsi_target_options_t3 += '"binding_basckstores": ["bs1"],' + iscsi_target_options_t3 += '"name": "iqn.2025-05.com.test:test03",}' + iscsi_target_options_t4 = '{"portal_ip": ["127.0.0.1"],' + iscsi_target_options_t4 += '"binding_basckstores" : ["bs2","bs1"],' + iscsi_target_options_t4 += '"name": "iqn.2025-05.com.test:test04",}' + iscsi_target_options_t5 = '{"portal_ip": ["127.0.0.1"],' + iscsi_target_options_t5 += '"binding_basckstores" : ["bs2","bs1"],}' diff --git a/qemu/tests/multi_targets.py b/qemu/tests/multi_targets.py new file mode 100644 index 0000000000..5f64fa4a66 --- /dev/null +++ b/qemu/tests/multi_targets.py @@ -0,0 +1,36 @@ +from virttest import data_dir +from virttest.iscsi import Iscsi + + +def run(test, params, env): + """ + Usage of multi-targets iscsi. + + + :param test: QEMU test object. + :param params: Dictionary with the test parameters. + :param env: Dictionary with test environment. + """ + vm = None + iscsi = None + logger = test.log + + try: + logger.info("Create iscsi disk.") + base_dir = data_dir.get_data_dir() + iscsi = Iscsi.create_iSCSI(params, base_dir) + iscsi.export_target() # or iscsi.export_target(target=["xxx"]) + iscsi.login() # or iscsi.login(target=["xxx"]) + targets = iscsi.query_targets() # or iscsi.query_targets(target=["xxx"]) + test.log.debug("iscsi.query_targets() returns: ") + test.log.debug(str(targets)) + + dev_name = iscsi.get_device_names() # or iscsi.get_device_names(target=["xxx"]) + test.log.debug("iscsi.get_device_names() returns: ") + test.log.debug(str(dev_name)) + finally: + logger.info("cleanup") + if vm and vm.is_alive(): + vm.destroy() + if iscsi: + iscsi.cleanup(confirmed=True)