@samitouri / QOSamiQemu / commits / 04a62cdfe8

tests/9p: add 3 xattr FID limit test cases (local fs driver)

Analogue to the previously added 3 synth tests, add (similar) 3 test cases using the "local" fs driver to verify correct xattr FID limit enforcement of 9pfs server with a real filesystem. These 3 new local tests use the shared test code of the previously added 3 synth tests. The only difference is that the local fs driver does not expose the current internal xattr FID counter, so we can't verify this with the local tests. This is a slow test (may take several seconds) and therefore registered as "slow" test and not running by default. Use -m slow to run this test. Link: https://lore.kernel.org/qemu-devel/d23fa874df4f474ee7cbe738a35c1483426057f0.1781361555.git.qemu_oss@crudebyte.com Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>

Christian Schoenebeck committed Jun 13, 2026 at 16:55 UTC 04a62cdfe873d07a5f264d03372bfc34bbcdddf0
1 file changed +67 -3
tests/qtest/virtio-9p-test.c
+67 -3
@@ -395,6 +395,19 @@ static void do_xattr_limit(QVirtio9P *v9p, int max_xattr, bool check_counter)
395 }
396 }
397
398 +static void do_local_xattr_limit(QVirtio9P *v9p, int max_xattr)
399 +{
400 + g_autofree char *test_file = virtio_9p_test_path("WRITE");
401 +
402 + /*
403 + * this file must be created for the test to work with the 'local' fs driver
404 + */
405 + g_file_set_contents(test_file, "", 0, NULL);
406 +
407 + /* the actual test code shared with the 'synth' fs driver tests */
408 + do_xattr_limit(v9p, max_xattr, false);
409 +}
410 +
411 static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc)
412 {
413 QVirtio9P *v9p = obj;
@@ -990,6 +1003,27 @@ static void fs_deep_absolute_path(void *obj, void *data,
1003 g_string_free(path, TRUE);
1004 }
1005
1006 +static void fs_local_xattr_limit_default(void *obj, void *data,
1007 + QGuestAllocator *t_alloc)
1008 +{
1009 + v9fs_set_allocator(t_alloc);
1010 + do_local_xattr_limit(obj, V9FS_MAX_XATTR_DEFAULT);
1011 +}
1012 +
1013 +static void fs_local_xattr_limit_custom(void *obj, void *data,
1014 + QGuestAllocator *t_alloc)
1015 +{
1016 + v9fs_set_allocator(t_alloc);
1017 + do_local_xattr_limit(obj, 100);
1018 +}
1019 +
1020 +static void fs_local_xattr_limit_unlimited(void *obj, void *data,
1021 + QGuestAllocator *t_alloc)
1022 +{
1023 + v9fs_set_allocator(t_alloc);
1024 + do_local_xattr_limit(obj, -1);
1025 +}
1026 +
1027 static void *synth_max_xattr_custom_opt(GString *cmd_line, void *arg)
1028 {
1029 virtio_9p_add_synth_driver_args(cmd_line, "max_xattr=100");
@@ -1008,20 +1042,42 @@ static void cleanup_9p_local_driver(void *data)
1042 virtio_9p_remove_local_test_dir();
1043 }
1044
1011 -static void *assign_9p_local_driver(GString *cmd_line, void *arg)
1045 +static void assign_9p_local_driver_with_args(GString *cmd_line,
1046 + const char *extra_opts)
1047 {
1048 /* make sure test dir for the 'local' tests exists */
1049 virtio_9p_create_local_test_dir();
1050
1016 - virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
1051 + g_autofree char *opts =
1052 + (extra_opts) ?
1053 + g_strdup_printf("security_model=mapped-xattr,%s", extra_opts) :
1054 + g_strdup("security_model=mapped-xattr");
1055 +
1056 + virtio_9p_assign_local_driver(cmd_line, opts);
1057
1058 g_test_queue_destroy(cleanup_9p_local_driver, NULL);
1059 +}
1060 +
1061 +static void *assign_9p_local_driver(GString *cmd_line, void *arg)
1062 +{
1063 + assign_9p_local_driver_with_args(cmd_line, NULL);
1064 return arg;
1065 }
1066
1022 -static void register_virtio_9p_test(void)
1067 +static void *local_max_xattr_custom_opt(GString *cmd_line, void *arg)
1068 {
1069 + assign_9p_local_driver_with_args(cmd_line, "max_xattr=100");
1070 + return arg;
1071 +}
1072
1073 +static void *local_max_xattr_unlimited_opt(GString *cmd_line, void *arg)
1074 +{
1075 + assign_9p_local_driver_with_args(cmd_line, "max_xattr=0");
1076 + return arg;
1077 +}
1078 +
1079 +static void register_virtio_9p_test(void)
1080 +{
1081 QOSGraphTestOptions opts = {
1082 };
1083
@@ -1078,6 +1134,14 @@ static void register_virtio_9p_test(void)
1134 &opts);
1135 qos_add_test("local/deep_absolute_path", "virtio-9p",
1136 fs_deep_absolute_path, &opts);
1137 + qos_add_test("local/xattr_limit/default", "virtio-9p",
1138 + fs_local_xattr_limit_default, &opts);
1139 + opts.before = local_max_xattr_custom_opt;
1140 + qos_add_test("local/xattr_limit/custom", "virtio-9p",
1141 + fs_local_xattr_limit_custom, &opts);
1142 + opts.before = local_max_xattr_unlimited_opt;
1143 + qos_add_test("local/xattr_limit/unlimited", "virtio-9p",
1144 + fs_local_xattr_limit_unlimited, &opts);
1145 }
1146
1147 libqos_init(register_virtio_9p_test);