Skip to content

Commit

Permalink
stop_con_vm_during_virtiofs: add a new testcase
Browse files Browse the repository at this point in the history
Signed-off-by: Houqi (Nick) Zuo <hzuo@redhat.com>
  • Loading branch information
nickzhq committed Nov 27, 2023
1 parent 0c3d5a8 commit d9ebb7c
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
31 changes: 31 additions & 0 deletions qemu/tests/cfg/virtio_fs_subtest_during_io.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- virtio_fs_subtest_during_io:
type = virtio_fs_subtest_during_io
virt_test_type = qemu
required_qemu = [4.2.0,)
kill_vm = yes
filesystems = fs
fs_driver = virtio-fs
force_create_fs_source = yes
remove_fs_source = yes
fs_target = 'myfs'
vm_mem_share = yes
vm_mem_backend = memory-backend-file
vm_mem_backend_path = /dev/shm
io_timeout = 600
fs_dest = '/mnt/${fs_target}'
fs_source_dir = virtio_fs_test/
driver_name = viofs
virtio_win_media_type = iso
cdroms += " virtio"
virtio_fs_test_file = "virtio_fs_test_file"
virtio_fs_cmd_dd = "dd if=/dev/urandom of=%s bs=1M count=700 iflag=fullblock"
Windows:
virtio_fs_cmd_dd = 'dd if=/dev/random of=%s bs=1M count=700'
i386, i686:
install_winfsp_path = 'C:\Program Files'
devcon_dirname = "x86"
x86_64:
install_winfsp_path = 'C:\Program Files (x86)'
devcon_dirname = "amd64"
devcon_path = "WIN_UTILS:\devcon\${devcon_dirname}\devcon.exe"
fs_driver_props = {"queue-size": 16}
93 changes: 93 additions & 0 deletions qemu/tests/virtio_fs_subtest_during_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import time
import os

from virttest import utils_test, utils_misc, utils_disk
from virttest import error_context
from virttest import data_dir

from provider import win_driver_utils
from provider import virtio_fs_utils


@error_context.context_aware
def run(test, params, env):
"""
Stop/continue the vm during the virtiofs test.
1) Boot guest with virtiofs device.
2) For windows guest, enable driver verifier first.
For the linux guest, skip this step.
3) Run virtiofs function test.
4) During steps 3, stop vm and then resume vm.
5) Memory leak check.
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
@error_context.context_aware
def stop_resume_vm_during_io_test():
start_time = time.time() # record the start time.
# run time expected, the unit is second.
max_run_time = params.get_numeric("max_run_time", 30)
while time.time() - start_time < max_run_time:
if os.path.exists(host_data) and os.path.getsize(host_data) > 0:
test.log.info("The file has been detected: %s" % host_data)
error_context.context("Going to stop the vm...", test.log.info)
vm.pause()
time.sleep(3)
error_context.context("Going to resume the vm...", test.log.info)
vm.resume()
break

driver = params["driver_name"]
driver_verifier = params.get("driver_verifier", driver)
driver_running = params.get('driver_running', driver_verifier)
timeout = int(params.get("login_timeout", 360))
fs_dest = params.get("fs_dest")
fs_target = params.get("fs_target")
test_file = params.get('virtio_fs_test_file')
fs_source = params.get("fs_source_dir")
base_dir = params.get("fs_source_base_dir", data_dir.get_data_dir())
if not os.path.isabs(fs_source):
fs_source = os.path.join(base_dir, fs_source)
host_data = os.path.join(fs_source, test_file)

vm_name = params['main_vm']
vm = env.get_vm(vm_name)
vm.verify_alive()
error_context.context("Boot guest with %s device" % driver, test.log.info)
session = vm.wait_for_login(timeout=timeout)

if params["os_type"] == "windows":
error_context.context("Run the viofs service", test.log.info)
utils_test.qemu.windrv_verify_running(session, test, driver_running)
session = utils_test.qemu.setup_win_driver_verifier(session,
driver_verifier,
vm)
virtio_fs_utils.run_viofs_service(test, params, session)
else:
error_context.context("Create a destination directory %s "
"inside guest." % fs_dest, test.log.info)
if not utils_misc.make_dirs(fs_dest, session=session):
test.fail("Creating directory was failed!")
error_context.context("Mount virtiofs target %s to %s inside"
" guest." % (fs_target, fs_dest),
test.log.info)
if not utils_disk.mount(fs_target, fs_dest, 'virtiofs',
session=session):
test.fail('Mount virtiofs target failed.')

pause_resume_vm = utils_misc.InterruptedThread(target=stop_resume_vm_during_io_test)
pause_resume_vm.daemon = True

error_context.context("Start the monitor thread's activity....",
test.log.info)
pause_resume_vm.start()
error_context.context("The monitor thread is running...", test.log.info)
virtio_fs_utils.basic_io_test(test, params, session)
pause_resume_vm.join()
error_context.context("The monitor thread is terminated...", test.log.info)

if params.get("os_type") == "windows":
win_driver_utils.memory_leak_check(vm, test, params)

0 comments on commit d9ebb7c

Please sign in to comment.