-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3784 from nickzhq/Virtiofs_support_for_file_syste…
…m_2218413 virtiofs_supp_for_fs: add a new test case
- Loading branch information
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
- virtio_fs_support_win_fs: | ||
type = virtio_fs_support_win_fs | ||
only Windows | ||
virt_test_type = qemu | ||
required_qemu = [4.2.0,) | ||
backup_image_before_testing = yes | ||
restore_image_after_testing = yes | ||
kill_vm = yes | ||
filesystems = fs | ||
fs_driver = virtio-fs | ||
force_create_fs_source = yes | ||
remove_fs_source = yes | ||
fs_target = 'myfs' | ||
fs_driver_props = {"queue-size": 1024} | ||
mem_devs = mem1 | ||
backend_mem_mem1 = memory-backend-file | ||
mem-path_mem1 = /dev/shm | ||
size_mem1 = ${mem}M | ||
use_mem_mem1 = no | ||
share_mem = yes | ||
guest_numa_nodes = shm0 | ||
numa_memdev_shm0 = mem-mem1 | ||
numa_nodeid_shm0 = 0 | ||
io_timeout = 600 | ||
fs_dest = '/mnt/${fs_target}' | ||
guest_username = "user00001" | ||
guest_username_pwd = "U1pwd345?a" | ||
add_user_cmd = "net user ${guest_username} ${guest_username_pwd} /add" | ||
fs_source_dir = virtio_fs_test/ | ||
driver_name = viofs | ||
virtio_win_media_type = iso | ||
cdroms += " virtio" | ||
# install winfsp tool | ||
i386, i686: | ||
executable_package_path = ":\7z-x86.exe" | ||
install_winfsp_path = 'C:\Program Files' | ||
x86_64: | ||
executable_package_path = ":\7z-x64.exe" | ||
install_winfsp_path = 'C:\Program Files (x86)' | ||
autoIt_path = ":\AutoIt3_%PROCESSOR_ARCHITECTURE%.exe" | ||
script_path = ":\simulate_right_click_on_7z.au3" | ||
reg_add_cmd = "reg add HKLM\Software\VirtIO-FS /v FileSystemName /d NTFS /t REG_SZ /f" | ||
reg_add_username = 'reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d ${guest_username} /f' | ||
reg_add_pwd = 'reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d ${guest_username_pwd} /f' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from virttest import error_context, utils_misc, utils_test | ||
|
||
from provider import virtio_fs_utils | ||
|
||
|
||
@error_context.context_aware | ||
def run(test, params, env): | ||
""" | ||
Virtiofs support for file system name specification (windows only). | ||
1) Before test, backup the image. | ||
2) Boot guest with virtiofs device. | ||
3) Install viofs driver. | ||
4) Create virtiofs service with administrator user and | ||
enable NTFS filesystem for virtiofs service. | ||
5) Copy a program like 7z-x64.exe and autoit script to the shared dir. | ||
6) Create a new user. | ||
7) login a common user and to install 7-zip with Admin privilege. | ||
8) After test, restore the image. | ||
:param test: QEMU test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment | ||
""" | ||
fs_target = params.get("fs_target") | ||
winutils_pack_path = params.get("executable_package_path") | ||
autoIt_path = params.get("autoIt_path") | ||
script_path = params.get("script_path") | ||
reg_add_username = params.get("reg_add_username") | ||
reg_add_pwd = params.get("reg_add_pwd") | ||
driver = params["driver_name"] | ||
driver_verifier = params.get("driver_verifier", driver) | ||
driver_running = params.get('driver_running', driver_verifier) | ||
|
||
vm = env.get_vm(params.get("main_vm")) | ||
vm.verify_alive() | ||
session = vm.wait_for_login() | ||
|
||
utils_test.qemu.windrv_verify_running(session, test, | ||
driver_running) | ||
session = utils_test.qemu.setup_win_driver_verifier(session, | ||
driver_verifier, | ||
vm) | ||
error_context.context("Create the viofs service.", test.log.info) | ||
virtio_fs_utils.create_viofs_service(test, params, session) | ||
error_context.context("Add NTFS filesystem to virtiofs.", test.log.info) | ||
reg_add_cmd = params.get("reg_add_cmd") | ||
session.cmd(reg_add_cmd) | ||
error_context.context("restart virtiofs service to make the registry " | ||
"change work.", test.log.info) | ||
virtio_fs_utils.stop_viofs_service(test, params, session) | ||
virtio_fs_utils.start_viofs_service(test, params, session) | ||
|
||
winutils_driver_letter = utils_misc.get_winutils_vol(session) | ||
shared_driver_letter = virtio_fs_utils.get_virtiofs_driver_letter(test, | ||
fs_target, | ||
session) | ||
winutils_pack_path = winutils_driver_letter + winutils_pack_path | ||
autoIt_path = winutils_driver_letter + autoIt_path | ||
script_path = winutils_driver_letter + script_path | ||
copy_cmd = "xcopy %s %s:\\ /Y" % (winutils_pack_path, shared_driver_letter) | ||
error_context.context("Copy the executable to shared dir.", | ||
test.log.info) | ||
session.cmd(copy_cmd) | ||
|
||
error_context.context("Create the new user", test.log.info) | ||
session.cmd(params.get("add_user_cmd")) | ||
error_context.context("Replace the default username and password with the " | ||
"new user.", test.log.info) | ||
session.cmd(reg_add_username) | ||
session.cmd(reg_add_pwd) | ||
error_context.context("Reboot the guest.", test.log.info) | ||
session = vm.reboot(session) | ||
result_on_shared = "%s:\\result.txt" % shared_driver_letter | ||
error_context.context("Run autoit script to install executable in " | ||
"explorer.", test.log.info) | ||
session.cmd("start /w " + autoIt_path + " " + script_path + " " + | ||
result_on_shared + " " + shared_driver_letter + ":") | ||
output = session.cmd_output("type " + result_on_shared) | ||
test.log.info("The title and text of the window are: %s", output) | ||
output_lower = output.lower() | ||
if ("7-zip" in output_lower and "setup" in output_lower | ||
and "install" in output_lower): | ||
test.log.info("Entry the installation windows of the package with " | ||
"Admin privilege successfully.") | ||
else: | ||
test.fail("Error detected while installing the " | ||
"executable package on the shared directory!\n " | ||
"Detail: %s" % output) |