Skip to content

Commit d454af4

Browse files
virtio_fs_rlimit_nofile: new case
1. Create a shared directory for testing on the host. 2. Touch 1024 files in the shared directory. 3. Start the virtiofsd daemon with rlimit-nofile and check. Signed-off-by: Tingting Mao <[email protected]>
1 parent 39966b3 commit d454af4

File tree

2 files changed

+177
-0
lines changed

2 files changed

+177
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
- virtio_fs_rlimit_nofile:
2+
only Linux
3+
no RHEL.6 RHEL.7 RHEL.8.0 RHEL.8.1
4+
no Host_RHEL.m6 Host_RHEL.m7 Host_RHEL.m8.u0 Host_RHEL.m8.u1
5+
type = virtio_fs_rlimit_nofile
6+
required_virtiofsd_version = [1.13.2-1,)
7+
virtiofsd_version_cmd = rpm -q virtiofsd | cut -d- -f2
8+
Win10.i386:
9+
mem = 4096
10+
fs_source_dir = /var/tmp/virtiofs_rlimit_nofile
11+
force_create_fs_source = yes
12+
remove_fs_source = yes
13+
14+
pre_command = "cd ${fs_source_dir}"
15+
pre_command += " && for i in $(seq 1 1024); do touch file_$i.txt; done"
16+
virtiofs_socket_path = '/var/tmp/virtiofs_rlimit_nofile.sock'
17+
cmd_run_virtiofsd = '/usr/libexec/virtiofsd --socket-path ${virtiofs_socket_path} --shared-dir ${fs_source_dir}'
18+
19+
vm_mem_share = yes
20+
vm_mem_backend = memory-backend-file
21+
vm_mem_backend_path = /dev/shm
22+
share_mem = yes
23+
!s390, s390x:
24+
mem_devs = mem1
25+
backend_mem_mem1 = memory-backend-file
26+
mem-path_mem1 = /dev/shm
27+
size_mem1 = ${mem}M
28+
use_mem_mem1 = no
29+
guest_numa_nodes = shm0
30+
numa_memdev_shm0 = mem-mem1
31+
numa_nodeid_shm0 = 0
32+
Windows:
33+
# install winfsp tool
34+
i386, i686:
35+
install_winfsp_path = 'C:\Program Files'
36+
devcon_dirname = 'x86'
37+
x86_64:
38+
install_winfsp_path = 'C:\Program Files (x86)'
39+
devcon_dirname = 'amd64'
40+
install_winfsp_cmd = 'msiexec /i WIN_UTILS:\winfsp.msi /qn'
41+
check_installed_cmd = 'dir "%s" |findstr /I winfsp'
42+
viofs_log_file = C:\viofs_log.txt
43+
viofs_svc_name = VirtioFsSvc
44+
viofs_exe_path = C:\virtiofs.exe
45+
viofs_exe_copy_cmd = xcopy %s C:\ /Y
46+
viofs_sc_create_cmd = 'sc create ${viofs_svc_name} binpath=${viofs_exe_path} start=auto'
47+
viofs_sc_create_cmd += ' depend="WinFsp.Launcher/VirtioFsDrv" DisplayName="Virtio FS Service"'
48+
viofs_sc_start_cmd = 'sc start ${viofs_svc_name}'
49+
viofs_sc_query_cmd = 'sc query ${viofs_svc_name}'
50+
viofs_sc_delete_cmd = 'sc delete ${viofs_svc_name}'
51+
debug_log_operation = 'enable'
52+
viofs_debug_enable_cmd = 'reg add HKLM\Software\VirtIO-FS /v DebugFlags /d 0xFFFFFFFF /t REG_DWORD'
53+
viofs_log_enable_cmd = 'reg add HKLM\Software\VirtIO-FS /v DebugLogFile /d ${viofs_log_file} /t REG_SZ'
54+
viofs_debug_delete_cmd = 'reg delete HKLM\Software\VirtIO-FS /v DebugFlags /f'
55+
viofs_log_delete_cmd = 'reg delete HKLM\Software\VirtIO-FS /v DebugLogFile /f'
56+
viofs_reg_query_cmd = 'reg query HKLM\Software\VirtIO-FS'
57+
virtio_win_media_type = iso
58+
cdroms += " virtio"
59+
check_str = 'A device attached to the system is not functioning'
60+
read_file_cmd = "type %s\${test_file}"
61+
write_file_cmd = "echo new_${test_data} > %s\${test_file}"
62+
variants:
63+
- rlimit_nofile_512:
64+
rlimit_nofile = 512
65+
cmd_run_virtiofsd += " --rlimit-nofile ${rlimit_nofile}"
66+
expected_msg = "Maximum number of file descriptors too small: Limit is 512, must be at least 610"
67+
- rlimit_nofile_610:
68+
rlimit_nofile = 610
69+
cmd_run_virtiofsd += " --rlimit-nofile ${rlimit_nofile}"
70+
expected_msg = "File descriptor count limit is very small, leaving only 0 file descriptors for the guest"
71+
- rlimit_nofile_1024:
72+
kill_vm = yes
73+
start_vm = yes
74+
filesystems = fs
75+
fs_driver = virtio-fs
76+
fs_source_type = mount
77+
force_create_fs_source = yes
78+
remove_fs_source = yes
79+
fs_target = 'myfs'
80+
fs_driver_props = {"queue-size": 1024}
81+
fs_dest = '/mnt/${fs_target}'
82+
driver_name = viofs
83+
rlimit_nofile = 1024
84+
fs_binary_extra_options += " --rlimit-nofile ${rlimit_nofile}"
85+
- rlimit_nofile_2048:
86+
kill_vm = yes
87+
start_vm = yes
88+
filesystems = fs
89+
fs_driver = virtio-fs
90+
fs_source_type = mount
91+
force_create_fs_source = yes
92+
remove_fs_source = yes
93+
fs_target = 'myfs'
94+
fs_driver_props = {"queue-size": 1024}
95+
fs_dest = '/mnt/${fs_target}'
96+
driver_name = viofs
97+
rlimit_nofile = 2048
98+
fs_binary_extra_options += " --rlimit-nofile ${rlimit_nofile}"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import aexpect
2+
from virttest import error_context
3+
from avocado.utils import process
4+
from virttest import (
5+
env_process, error_context, utils_disk, utils_misc, utils_test
6+
)
7+
8+
9+
@error_context.context_aware
10+
def run(test, params, env):
11+
"""
12+
Test virtio-fs rlimit-nofile.
13+
Steps:
14+
1. Create a shared directory for testing on the host.
15+
2. Touch 1024 files in the shared directory.
16+
3. Start the virtiofsd daemon with rlimit-nofile and check.
17+
18+
:param test: QEMU test object.
19+
:param params: Dictionary with the test parameters.
20+
:param env: Dictionary with test environment.
21+
"""
22+
rlimit_nofile = params.get("rlimit_nofile")
23+
cmd_run_virtiofsd = params["cmd_run_virtiofsd"]
24+
25+
if rlimit_nofile == "512":
26+
expected_msg = params["expected_msg"]
27+
error_context.context(
28+
"Starting virtiofsd with rlimit-nofile=%s" % rlimit_nofile,
29+
test.log.info)
30+
result = process.run(
31+
cmd_run_virtiofsd,
32+
shell=True,
33+
ignore_status=True,
34+
verbose=True,
35+
)
36+
status, out = result.exit_status, result.stdout.decode()
37+
if status == 0:
38+
test.fail(
39+
"virtiofsd unexpectedly started successfully with "
40+
"rlimit-nofile=512"
41+
)
42+
elif expected_msg not in out:
43+
test.fail(
44+
"virtiofsd failed but without expected message. Output: %s" % out)
45+
error_context.context(
46+
"virtiofsd failed as expected with the required message present",
47+
test.log.info)
48+
elif rlimit_nofile == "610":
49+
expected_msg = params["expected_msg"]
50+
error_context.context(
51+
"Starting virtiofsd with rlimit-nofile=%s" % rlimit_nofile,
52+
test.log.info)
53+
session = aexpect.ShellSession(
54+
cmd_run_virtiofsd,
55+
auto_close=False,
56+
output_func=utils_misc.log_line,
57+
output_params=("virtiofs_fs-virtiofs.log",),
58+
prompt=r"^\[.*\][\#\$]\s*$",
59+
)
60+
try:
61+
session.expect(expected_msg, timeout=10)
62+
test.log.info(
63+
"virtiofsd started successfully with the required message "
64+
"present"
65+
)
66+
except aexpect.ExpectTimeout as e:
67+
test.fail("Timeout for virtiofsd start with rlimit-nofile=610: %s" % e)
68+
finally:
69+
session.close()
70+
elif rlimit_nofile == "1024":
71+
error_context.context(
72+
"Starting virtiofsd with rlimit-nofile=%s" % rlimit_nofile,
73+
test.log.info)
74+
vm = env.get_vm(params.get("main_vm"))
75+
vm.verify_alive()
76+
session = vm.wait_for_login()
77+
session.close()
78+
else:
79+
test.fail("Invalid rlimit-nofile: %s" % rlimit_nofile)

0 commit comments

Comments
 (0)