Skip to content

Commit

Permalink
Add wait in create_scsi_disk method
Browse files Browse the repository at this point in the history
In some extreme situation, although loading scsi_debug module is returned smoothly,
but still it leads to failure in finding scsi device

Signed-off-by: chunfuwen <[email protected]>
  • Loading branch information
chunfuwen committed Aug 4, 2023
1 parent fb39a11 commit 4ead539
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2876,8 +2876,18 @@ def create_scsi_disk(scsi_option, scsi_size="2048"):
# Unload it first if it's already loaded.
if linux_modules.module_is_loaded("scsi_debug"):
linux_modules.unload_module("scsi_debug")

linux_modules.load_module("scsi_debug dev_size_mb=%s %s" %
(scsi_size, scsi_option))

def _get_scsi_disk():
"""attempt to get scsi disk multiple times until getting real one"""
scsi_disk = process.run("lsscsi|grep scsi_debug|awk '{print $6}'",
shell=True).stdout_text.strip()
return scsi_disk is not None

utils_misc.wait_for(lambda: _get_scsi_disk(),
timeout=10, ignore_errors=True)
# Get the scsi device name
result = process.run("lsscsi|grep scsi_debug|awk '{print $6}'",
shell=True)
Expand Down

0 comments on commit 4ead539

Please sign in to comment.