Skip to content

[Draft] Test only #4303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions qemu/tests/cfg/multi_targets.cfg
Original file line number Diff line number Diff line change
@@ -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"],}'
36 changes: 36 additions & 0 deletions qemu/tests/multi_targets.py
Original file line number Diff line number Diff line change
@@ -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)