[Devel] [PATCH hci-8.1 2/2] selftests/ve: check that host can go over container mount limit
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Sep 28 18:24:58 MSK 2026
Like pseudosuper_allows_overuse, check that a bind mount done from ve0
in the container mount namespace succeeds when the container has no
mounts left, and is charged to the container.
https://virtuozzo.atlassian.net/browse/VSTOR-147661
Feature: per-ve failcounters
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
.../selftests/ve/ve_mount_accounting_test.c | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tools/testing/selftests/ve/ve_mount_accounting_test.c b/tools/testing/selftests/ve/ve_mount_accounting_test.c
index e2a882137e11d..8bb13e9615427 100644
--- a/tools/testing/selftests/ve/ve_mount_accounting_test.c
+++ b/tools/testing/selftests/ve/ve_mount_accounting_test.c
@@ -539,6 +539,43 @@ TEST_F(ve_mnt_acc, failcount)
ASSERT_TRUE(strstr(failcount_str, "mnt: 1\n") != NULL);
}
+static int _create_bind_mount(void *id_ptr)
+{
+ char path[PATH_MAX];
+ int id = *(int *)id_ptr;
+
+ snprintf(path, sizeof(path), TMP_DIR "%d", id);
+
+ if (mkdir(path, 0755) < 0) {
+ fprintf(stderr, "Failed to create directory %s: %s\n", path, strerror(errno));
+ return -1;
+ }
+ if (!mount(path, path, NULL, MS_BIND, NULL))
+ return 0;
+ fprintf(stderr, "Failed to bind mount %s: %s\n", path, strerror(errno));
+
+ rmdir(path);
+ return -1;
+}
+
+/* Test that host can go over the limit in container mount namespace. */
+TEST_F(ve_mnt_acc, host_allows_overuse)
+{
+ char path_max_nr[64];
+ int id = 0;
+
+ snprintf(path_max_nr, sizeof(path_max_nr), "%d/ve.mnt_max_nr", self->ctid);
+
+ ASSERT_EQ(write_u64_at(self->cgv2_fd, path_max_nr, self->orig_have_mnt), 0);
+
+ /* Bind mount from ve0, charged to the container's mount namespace owner */
+ ASSERT_EQ(run_in_ve(self->cgv2_fd, self->ctid, &self->ns_ctx,
+ CLONE_NEWNS, _create_bind_mount, &id), 0);
+ ASSERT_EQ(wait_on_mnt_avail(self, -1), 0);
+
+ ASSERT_EQ(destroy_mount(self, 0), 0);
+}
+
int main(int argc, char **argv)
{
need_avail = mmap(NULL, sizeof(int),
--
2.55.0
More information about the Devel
mailing list