提交 c0c8bc21 编写于 作者: X Xu Tian

Merge pull request #527 from luckyh/ppc-virtblk-disk

Replace the method of getting target drive path
......@@ -9,6 +9,9 @@
image_snapshot_stg1 = no
drive_index_stg1 = 3
image_boot_stg1 = no
blk_extra_params_stg1 = "serial=TARGET_DISK0"
Host_RHEL.m6..ide:
blk_extra_params_stg1 = "wwn=0x5000123456789abc"
dd_count = 1
# last input and output disk
dd_if_select = -1
......@@ -19,9 +22,9 @@
variants:
- zero2disk:
dd_if = ZERO
dd_of = /dev/[shv]d?
dd_of = stg1
- disk2null:
dd_if = /dev/[shv]d?
dd_if = stg1
dd_of = NULL
- readonly:
# ide, ahci don't support readonly disks
......@@ -30,9 +33,9 @@
variants:
- zero2disk:
dd_if = ZERO
dd_of = /dev/[shv]d?
dd_of = stg1
dd_stat = 1
- disk2null:
dd_if = /dev/[shv]d?
dd_if = stg1
dd_of = NULL
dd_stat = 0
......@@ -17,7 +17,12 @@
- lvm_create:
type = lvm
force_create_image_stg1 = yes
blk_extra_params_stg1 = "serial=TARGET_DISK1"
force_create_image_stg2 = yes
blk_extra_params_stg2 = "serial=TARGET_DISK2"
Host_RHEL.m6..ide:
blk_extra_params_stg1 = "wwn=0x5000123456789abc"
blk_extra_params_stg2 = "wwn=0x5000cba987654321"
clean = no
- lvm_fill: lvm_create
type = fillup_disk
......
......@@ -8,6 +8,7 @@ import logging
import aexpect
from autotest.client.shared import error
from virttest import utils_misc
@error.context_aware
......@@ -30,6 +31,12 @@ def run(test, params, env):
return "/dev/random"
elif filename == "URANDOM":
return "/dev/urandom"
elif filename in params.objects("images"):
drive_id = params["blk_extra_params_%s" % filename].split("=")[1]
drive_path = utils_misc.get_linux_drive_path(session, drive_id)
if drive_path:
return drive_path
raise error.TestError("Failed to get '%s' drive path" % filename)
else:
# get all matching filenames
try:
......
......@@ -2,6 +2,7 @@ import os
import logging
from autotest.client.shared import error
from virttest import utils_misc
@error.context_aware
......@@ -43,9 +44,15 @@ def run(test, params, env):
lv_path = "/dev/%s/%s" % (vg_name, lv_name)
clean = params.get("clean", "yes")
timeout = params.get("lvm_timeout", "600")
output = session.cmd_output("ls /dev/[hvs]da")
disk_prefix = output.strip()[:len('/dev/hd')]
disks = "%sb %sc" % (disk_prefix, disk_prefix)
disk_list = []
for disk in params.objects("images")[-2:]:
d_id = params["blk_extra_params_%s" % disk].split("=")[1]
d_path = utils_misc.get_linux_drive_path(session, d_id)
if not d_path:
raise error.TestError("Failed to get '%s' drive path" % d_id)
disk_list.append(d_path)
disks = " ".join(disk_list)
try:
error.context("adding physical volumes %s" % disks, logging.info)
......
......@@ -67,7 +67,14 @@ def run(test, params, env):
data_dir.get_data_dir())
data_image_dev = vm.get_block({'file': data_image_filename})
block_size_cmd = params["block_size_cmd"]
drive_path = ""
if params.get("os_type") == 'linux':
drive_id = params["blk_extra_params_%s" % data_image].split("=")[1]
drive_path = utils_misc.get_linux_drive_path(session, drive_id)
if not drive_path:
raise error.TestError("Failed to get '%s' drive path" % data_image)
block_size_cmd = params["block_size_cmd"].format(drive_path)
block_size_pattern = params.get("block_size_pattern")
need_reboot = params.get("need_reboot", "no") == "yes"
accept_ratio = float(params.get("accept_ratio", 0))
......
......@@ -9,7 +9,10 @@
image_name_stg = images/stg
create_image_stg = yes
force_create_image_stg = yes
block_size_cmd = "fdisk -l|grep /dev/*db"
blk_extra_params_stg = "serial=TARGET_DISK0"
Host_RHEL.m6..ide:
blk_extra_params_stg = "wwn=0x5000123456789abc"
block_size_cmd = "fdisk -l | grep {0}"
block_size_pattern = ",\s+(\d+\s+b)ytes"
disk_change_ratio = "1.5 0.5"
guest_prepare_cmd = ""
......
......@@ -5,18 +5,21 @@
boot_drive_disk1 = yes
image_name_disk1 = images/storage
image_size_disk1 = 10G
blk_extra_params_disk1 = "serial=TARGET_DISK0"
Host_RHEL.m6..ide:
blk_extra_params_disk1 = "wwn=0x5000123456789abc"
force_create_image_disk1 = yes
kill_vm = yes
cmd_timeout = 1200
# The following parameters will be overriden in guest-os config files.
create_partition_cmd = ""
format_cmd = "cd /dev && for i in `ls | egrep [shv]db`;do yes |mkfs.ext3 $i; done"
format_cmd = "yes | mkfs.ext3 {0}"
list_disk_cmd = ""
set_online_cmd = ""
show_dev_cmd = "cd /dev && ls | egrep [shv]db"
mount_cmd = "mkdir -p /media && cd /dev && ls | egrep [shv]db | xargs -I dev mount -t ext3 dev /media"
show_mount_cmd = "mount | grep -Eo '/dev/[shv]db'"
umount_cmd = "mount | grep -Eo '/dev/[shv]db' | xargs umount"
show_dev_cmd = "ls {0}"
mount_cmd = "mkdir -p /media && mount -t ext3 {0} /media"
show_mount_cmd = "mount | grep {0}"
umount_cmd = "umount {0}"
testfile_name = "/media/format_disk-test.txt"
writefile_cmd = "echo %s > %s"
readfile_cmd = "cat %s"
......@@ -33,6 +33,17 @@ def run(test, params, env):
session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
cmd_timeout = int(params.get("cmd_timeout", 360))
drive_path = ""
if params.get("os_type") == 'linux':
drive_name = params.objects("images")[-1]
drive_id = params["blk_extra_params_%s" % drive_name].split("=")[1]
drive_path = utils_misc.get_linux_drive_path(session, drive_id)
if not drive_path:
raise error.TestError("Failed to get '%s' drive path" % drive_name)
show_dev_cmd = params["show_dev_cmd"].format(drive_path)
show_mount_cmd = params["show_mount_cmd"].format(drive_path)
# Create a partition on disk
create_partition_cmd = params.get("create_partition_cmd")
if create_partition_cmd:
......@@ -58,7 +69,7 @@ def run(test, params, env):
raise error.TestFail(
"Failed to create partition with error: %s" % output)
format_cmd = params.get("format_cmd")
format_cmd = params.get("format_cmd").format(drive_path)
if format_cmd:
error.context("Format the disk with cmd '%s'" % format_cmd,
logging.info)
......@@ -67,12 +78,11 @@ def run(test, params, env):
if status != 0:
raise error.TestFail("Failed to format with error: %s" % output)
mount_cmd = params.get("mount_cmd")
mount_cmd = params.get("mount_cmd").format(drive_path)
if mount_cmd:
error.context("Mount the disk with cmd '%s'" % mount_cmd, logging.info)
status, output = session.cmd_status_output(mount_cmd, timeout=cmd_timeout)
if status != 0:
show_dev_cmd = params["show_dev_cmd"]
device_list = session.cmd_output_safe(show_dev_cmd)
logging.debug("The devices which will be mounted are: %s" % device_list)
raise error.TestFail("Failed to mount with error: %s" % output)
......@@ -105,12 +115,11 @@ def run(test, params, env):
raise error.TestFail("The content written to file has changed, "
"from: %s, to: %s" % (ranstr, output.strip()))
umount_cmd = params.get("umount_cmd")
umount_cmd = params.get("umount_cmd").format(drive_path)
if umount_cmd:
error.context("Unmounting disk(s) after file write/read operation")
status, output = session.cmd_status_output(umount_cmd, timeout=cmd_timeout)
if status != 0:
show_mount_cmd = params["show_mount_cmd"]
mount_list = session.cmd_output_safe(show_mount_cmd)
logging.debug("The mounted devices are: %s" % mount_list)
raise error.TestFail("Failed to umount with error: %s" % output)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册