提交 0c425a78 编写于 作者: X Xu Han

cgroup: Fix the bug of getting scsi_debug disk

Signed-off-by: NXu Han <xuhan@redhat.com>
上级 2e7f3018
......@@ -19,6 +19,7 @@ from aexpect import ShellTimeoutError
from virttest.env_process import preprocess
from virttest import qemu_monitor
from virttest import error_context
from virttest import utils_misc
from virttest.staging import utils_memory
from virttest.staging.utils_cgroup import Cgroup
......@@ -1503,6 +1504,18 @@ def run(test, params, env):
return True
def _get_scsi_debug_disk():
cmd = ("ls -1 /sys/bus/pseudo/drivers/scsi_debug/adapter*/"
"host*/target*/*/block | grep ^sd | head -1")
name = process.system_output(cmd, shell=True, verbose=False,
ignore_status=True).decode()
if not name:
return None
node_path = "/dev/%s" % name
if not os.path.exists(node_path):
return None
return node_path
logging.info("Setup test")
vm = env.get_all_vms()[0]
# Try to find suitable monitor
......@@ -1549,8 +1562,9 @@ def run(test, params, env):
process.system("modprobe scsi_debug dev_size_mb=8 add_host=0")
process.system("echo 1 > /sys/bus/pseudo/drivers/scsi_debug/add_host",
shell=True)
time.sleep(0.1)
disk = process.system_output("ls /dev/sd* | tail -n 1", shell=True)
disk = utils_misc.wait_for(_get_scsi_debug_disk, 5)
if not disk:
test.error("Could not get the device node generated by scsi_debug")
dev = "%s:%s" % get_maj_min(disk)
permissions = [
{'property': 'deny',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册