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 87b6971
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions virttest/utils_test/libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,15 @@ def create_scsi_disk(scsi_option, scsi_size="2048"):
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 87b6971

Please sign in to comment.