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;
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");
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
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);