Skip to content

Commit

Permalink
Merge pull request #6095 from iccaszhulili/virtiofs_openfiles
Browse files Browse the repository at this point in the history
Add the cases of virtiofs openfiles
  • Loading branch information
Yingshun authored Jan 16, 2025
2 parents ab9e4f1 + 2739c3e commit 5930c34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions libvirt/tests/cfg/virtual_device/filesystem_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
variants:
- thread_pool_16:
thread_pool_size = 16
openfiles = "yes"
only positive_test..nop..xattr_on.cache_mode_auto, positive_test..detach_device..xattr_on.cache_mode_auto
- thread_pool_noset:
variants:
Expand Down
16 changes: 14 additions & 2 deletions libvirt/tests/src/virtual_device/filesystem_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def generate_expected_process_option():
# virtiofsd man pages. Add another kind of pattern here to avoid
# possible change in the future again.
expected_results += " --thread-pool-size(\s|=)%s" % thread_pool_size
if openfiles:
expected_results += " --rlimit-nofile(\s|=)%s" % open_files_max
logging.debug(expected_results)
return expected_results

Expand Down Expand Up @@ -226,6 +228,7 @@ def check_filesystem_hotplug_with_mem_setup():
xattr = params.get("xattr", "on")
path = params.get("virtiofsd_path", "/usr/libexec/virtiofsd")
thread_pool_size = params.get("thread_pool_size")
openfiles = params.get("openfiles", "no") == "yes"
queue_size = int(params.get("queue_size", "512"))
driver_type = params.get("driver_type", "virtiofs")
guest_num = int(params.get("guest_num", "1"))
Expand Down Expand Up @@ -279,6 +282,13 @@ def check_filesystem_hotplug_with_mem_setup():
libvirt_version.is_libvirt_feature_supported(params)
check_filesystem_hotplug_with_mem_setup()
return

if openfiles:
with open('/proc/sys/fs/nr_open', 'r') as file:
open_files_max = file.read().strip()
else:
open_files_max = None

# Define filesystem device xml
for index in range(fs_num):
driver = {'type': driver_type, 'queue': queue_size}
Expand All @@ -289,8 +299,10 @@ def check_filesystem_hotplug_with_mem_setup():
source = {'socket': source_socket}
target = {'dir': target_dir}
if launched_mode == "auto":
binary_keys = ['path', 'cache_mode', 'xattr', 'thread_pool_size']
binary_values = [path, cache_mode, xattr, thread_pool_size]
binary_keys = ['path', 'cache_mode', 'xattr',
'thread_pool_size', "open_files_max"]
binary_values = [path, cache_mode, xattr,
thread_pool_size, open_files_max]
binary_dict = dict(zip(binary_keys, binary_values))
source = {'dir': source_dir}
accessmode = "passthrough"
Expand Down

0 comments on commit 5930c34

Please sign in to comment.