From 2739c3eb5fe0a10e0e2f600e2b826eab7e399718 Mon Sep 17 00:00:00 2001 From: Lili Zhu Date: Sun, 29 Dec 2024 07:40:34 -0500 Subject: [PATCH] Add the cases of virtiofs openfiles Signed-off-by: Lili Zhu --- .../cfg/virtual_device/filesystem_device.cfg | 1 + .../src/virtual_device/filesystem_device.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libvirt/tests/cfg/virtual_device/filesystem_device.cfg b/libvirt/tests/cfg/virtual_device/filesystem_device.cfg index 76a1352cc9..0114840e71 100644 --- a/libvirt/tests/cfg/virtual_device/filesystem_device.cfg +++ b/libvirt/tests/cfg/virtual_device/filesystem_device.cfg @@ -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: diff --git a/libvirt/tests/src/virtual_device/filesystem_device.py b/libvirt/tests/src/virtual_device/filesystem_device.py index cf4d9361b2..9067d85c3a 100644 --- a/libvirt/tests/src/virtual_device/filesystem_device.py +++ b/libvirt/tests/src/virtual_device/filesystem_device.py @@ -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 @@ -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")) @@ -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} @@ -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"