OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>,
	Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>,
	Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 2/2] selftests/ve: check that host can go over container mount limit
Date: Mon, 28 Sep 2026 17:24:58 +0200	[thread overview]
Message-ID: <20260928-b4-ve0-mnt-limit-v1-2-66456b9eaf6f@virtuozzo.com> (raw)
In-Reply-To: <20260928-b4-ve0-mnt-limit-v1-0-66456b9eaf6f@virtuozzo.com>

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@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

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-09-28 15:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 15:24 [Devel] [PATCH hci-8.1 0/2] ve/fs: allow host to " Pavel Tikhomirov
2026-09-28 15:24 ` [Devel] [PATCH hci-8.1 1/2] ve/fs: allow host to go over limit of container mount namespace Pavel Tikhomirov
2026-09-28 15:24 ` Pavel Tikhomirov [this message]
2026-09-30 15:05 ` [Devel] [PATCH hci-8.1 0/2] ve/fs: allow host to go over container mount limit Konstantin Khorenko
2026-09-30 15:09 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260928-b4-ve0-mnt-limit-v1-2-66456b9eaf6f@virtuozzo.com \
    --to=ptikhomirov@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    --cc=vladimir.riabchun@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox