OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>,
	khorenko@virtuozzo.com, vasileios.almpanis@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 1/3] selftests/ve: open the host cgroup2 mount instead of creating one
Date: Thu, 19 Nov 2026 07:53:47 +0000	[thread overview]
Message-ID: <010701a1f2cc2398-2bf70dcc-383a-4612-b5d6-0990ea9bd20e-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261119074808.478064-2-mirian.shilakadze@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/ve: open_cg2_fd() fails instead of skipping when
  cgroup2 is not at /sys/fs/cgroup
- [Low] selftests/ve: stale 'cgroup2 mount' log messages in
  ve_cpuid_override_test.c
--

commit 35c219f99551e9d27fa90449ba5b0180826c3af5
Author: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

selftests/ve: open the host cgroup2 mount instead of creating one

The commit replaces mount_cg2_fd(), which created a fresh cgroup2 mount with fsopen()/fsconfig()/fsmount(), with open_cg2_fd(). The new helper opens /sys/fs/cgroup and checks with fstatfs() that it is cgroup2. This stops each fixture setup from clearing nsdelegate and memory_recursiveprot on the host hierarchy. All callers are switched over.

> diff --git a/tools/testing/selftests/ve/ve_cpuid_override_test.c b/tools/testing/selftests/ve/ve_cpuid_override_test.c
> index b9f5e49d6c43..b52e4141ab99 100644
> --- a/tools/testing/selftests/ve/ve_cpuid_override_test.c
> +++ b/tools/testing/selftests/ve/ve_cpuid_override_test.c
> @@ -153,7 +153,7 @@ FIXTURE_SETUP(ve_cpuid_override)
>  		 self->host.edx & ~self->bit);
>  
>  	/* Last, so that a failed ASSERT above leaves no VE cgroup behind. */
> -	self->cgv2_fd = mount_cg2_fd();
> +	self->cgv2_fd = open_cg2_fd();
>  	ASSERT_GE(self->cgv2_fd, 0) TH_LOG("cgroup2 mount: %s", strerror(errno));

[Severity: Low]
This isn't a bug, but this message still says "cgroup2 mount" although
open_cg2_fd() no longer mounts anything. The commit message says the
messages that said "mount" now say "open". The TH_LOG() in
FIXTURE_TEARDOWN_PARENT(ve_cpuid_override), "cgroup2 mount: %s, VE cgroup
%d left behind", was missed in the same way. Could both be changed to
"cgroup2 open"?

[ ... ]

> diff --git a/tools/testing/selftests/ve/ve_perms_test.c b/tools/testing/selftests/ve/ve_perms_test.c
> index c57325d10901..375f98c36f87 100644
> --- a/tools/testing/selftests/ve/ve_perms_test.c
> +++ b/tools/testing/selftests/ve/ve_perms_test.c
> @@ -189,7 +189,7 @@ static int default_granted(int cgv2_fd, const char *fs, const char *entry)
>  
>  FIXTURE_SETUP(ve_perms)
>  {
> -	self->cgv2_fd = mount_cg2_fd();
> +	self->cgv2_fd = open_cg2_fd();
>  	ASSERT_GE(self->cgv2_fd, 0);

[ ... ]

> diff --git a/tools/testing/selftests/ve/ve_selftest.h b/tools/testing/selftests/ve/ve_selftest.h
> index 1fc3f8dcac18..af7725600453 100644
> --- a/tools/testing/selftests/ve/ve_selftest.h
> +++ b/tools/testing/selftests/ve/ve_selftest.h
> @@ -245,23 +245,26 @@ static inline int read_s32_at(int dirfd, const char *path,
[ ... ]
> +static inline int open_cg2_fd(void)
>  {
> -	int fs_fd, mnt_fd;
> +	struct statfs st;
> +	int fd;
>  
> -	fs_fd = fsopen("cgroup2", 0);
> -	if (fs_fd < 0)
> +	fd = open("/sys/fs/cgroup", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
> +	if (fd < 0)
>  		return -1;
> -
> -	if (fsconfig(fs_fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0) {
> -		close(fs_fd);
> +	if (fstatfs(fd, &st) < 0 || st.f_type != CGROUP2_SUPER_MAGIC) {
> +		close(fd);
> +		errno = ENODEV;
>  		return -1;

[Severity: Low]
Should a missing cgroup2 at /sys/fs/cgroup be treated as a skip rather
than a failure? On a host with a cgroup v1 or hybrid layout, or where the
path is absent, open_cg2_fd() returns -1 with errno set to ENODEV. Most
callers, such as the FIXTURE_SETUP(ve_perms) above, only do
ASSERT_GE(self->cgv2_fd, 0), so they report a hard failure. Only
ve_numa_migrate and ve_vtty_stress turn the error into a skip. The old
mount_cg2_fd() worked on those hosts, and the commit message does not
mention the new assumption about the host layout. Could the callers skip
with a reason in this case?

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119074808.478064-1-mirian.shilakadze@virtuozzo.com?part=1

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

  reply	other threads:[~2026-11-19  7:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  7:48 [Devel] [PATCH hci-8.2 0/3] selftests/ve: move ve_devcg_bpf and ve_printk into ve/ Mirian Shilakadze
2026-11-19  7:48 ` [Devel] [PATCH hci-8.2 1/3] selftests/ve: open the host cgroup2 mount instead of creating one Mirian Shilakadze
2026-11-19  7:53   ` no-reply [this message]
2026-11-19  7:48 ` [Devel] [PATCH hci-8.2 2/3] selftests/ve: move ve_devcg_bpf into ve/ and reuse ve_selftest.h Mirian Shilakadze
2026-11-19  7:54   ` no-reply
2026-11-19  7:48 ` [Devel] [PATCH hci-8.2 3/3] selftests/ve: move ve_printk " Mirian Shilakadze
2026-11-19  7:56   ` no-reply

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=010701a1f2cc2398-2bf70dcc-383a-4612-b5d6-0990ea9bd20e-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=mirian.shilakadze@virtuozzo.com \
    --cc=vasileios.almpanis@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