From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 6EF7480027 for ; Thu, 19 Nov 2026 07:49:43 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJ7mRfr003663; Thu, 19 Nov 2026 10:48:28 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJ7mRfr003663 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="pgHRcKqE" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJ7mGFU003634 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 19 Nov 2026 10:48:16 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJ7mGFU003634 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-490c1867460so1123635f8f.2 for ; Wed, 18 Nov 2026 23:48:16 -0800 (PST) X-Gm-Message-State: APuU4Z/as4kboUpPjw8ScuQOxAh9wZ3jCMWN7mqiEgV9m4UPHHmpQBVB 2usIyutZCbFXyYf7T9voXYvpCjkeJAiFQ1sfAEFpJdHKqEHJ286+TwyeykfjfVDJzd8YgzM/l05 Bf3DtW2MOyg8M/05+ylXEsKLcD7rUzQ4Zx8M5SohFMf/Lyv8eVqWxmA== X-Gm-Gg: AZFdTZfz9q/I1fPIWEfpi2Cl7sKJNV3ILCxg1wKNrlw8inTcAxvpmxPJ+wH51OzpXL8 rjSD0H8LAt6ThfRTmamaqpMZE+GMOJ16FIzVHLb5lATKLr3fepQ0CQzfSu369cp4yHCp1vohGCz 0Vv+m0FPIkDhTmqb3SxkTUwhCb47/r15o8G9FRYI/Ve8jqLcRMVvAiLSITn4dp11WaJlIvXuxFw n7QSTyyMLPjKnXZVFBfZwoC3I2JATPFUPCP9lrkUZGZeYcDIBZGBQx1fVKDdADTs+4ljBQUD6q6 dTMg52t+ag5EA5b0INXghala5ORqrPxj4PDh5mQ3p4DfkHmvbSShYPrIXLJE+6Ez5CmycW9bwld flCGC+iZETl8OUk/ua6lAJ6oQCivQMQ== X-Received: by 2002:a05:6000:2602:b0:48d:f470:6b3e with SMTP id ffacd0b85a97d-4a63ae56784mr9599196f8f.13.1795074496147; Wed, 18 Nov 2026 23:48:16 -0800 (PST) X-Received: by 2002:a05:6000:2602:b0:48d:f470:6b3e with SMTP id ffacd0b85a97d-4a63ae56784mr9599144f8f.13.1795074495505; Wed, 18 Nov 2026 23:48:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795074495; cv=none; d=google.com; s=arc-20260327; b=XBE7//DAdFv+KawYWuKMrs0JjKzcWSrAoSZygblr1kPShMjlyFBn4QLZ0Bga36VhDV ymlC6qPcKJyDr4PunEuYPY+JCIFdS2ZU9rSaTXpVwZt1YmQFReuiOauCwnBdxAXhE1yh 1GsSu7/cywvw6iob8M2DwgZV6bTLPEW6X4WRvAtx+HIKQtCqtjkydQhfs3P0x5WC56nX 7ZfAPsBQavA0ZP5LF1LPTI7xRFS1gOYH8PgFPOjMrUmhHTtXU8Dv55Q1O+06akWzNf3b +M/B+KWjCJ69tztt5MUE+PXiplvZxbF8Aw3fF1pPr43jTgcMVXgLxNLRTszyCys6F7Qd Wp7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=l4CQcEwnboZ0vqwMWGzxvuq95mlYSxUrWR9KDAxZVrM=; fh=teuuu96aRhCopkXuOxFj+Q2skgkILGdRv1xYtdVIE7A=; b=gZS7HwF+tyjV/QnIxLPs0Txn072ZcyY7e6SJTBfCHZYdA2rZ8u4o0QE1CsMJg8oKzM wEaQN3os4JFr2IJwPa59/zbUQ1S4UIEFUTuaObKJ/hh48ElqMqbk1OeH+pvMikE2xn6G 7VEknt39zXMXxO1pOnGXoK5XGcbVGa8VpKpmgV38MHA8BWmRd1WQN5VMJ6s4WmojBD+A 1I1zZcN7WOfSfjoR9P35jGErBCUyjeSNdz8EE9e6ni747TsMklnpgYAIcxA21xgmKPOR bBlUGGWZNHUYkCe3+9jixEQKKYD3Veuur2QpbIiB7GJZ/iBDQWbu5i/VIf2L7F34yhCN 6Tlw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=pgHRcKqE; spf=pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=mirian.shilakadze@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-4a6574b1686si9962555f8f.145.2026.11.18.23.48.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 23:48:15 -0800 (PST) Received-SPF: pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=pgHRcKqE; spf=pass (google.com: domain of mirian.shilakadze@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=mirian.shilakadze@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=l4CQcEwnboZ0vqwMWGzxvuq95mlYSxUrWR9KDAxZVrM=; b=pgHRcKqEVgd6 3SKGNET4JkM2SM3oJkKaXvMxtBniz6O7llcJDW7CJkjXBECLb4eDzwSOlxXLm9hWUdYCM8d8eZdi7 sCjfSduweakZCktkKKuXli9K7Uqc2Y5uHgs+nrPoybK38F6A2RVPEGa6eZ8qdZe6Ai3IVWZoiynjo Upj/AXJBsbbEEK9uG/+xCusFc0C/GowjQG6XAeDNo7ScthBF1IX5D4x0r7ZueDH15J6xXBhNG/lrV eOn/Du5PoANCnOe+YJyv0QMLOc56aeoty6TxD04Os6DdyGXWi/shxBnUS29ErDhXIDN/IFP1i77Bd LiQ7btR+8xzhm181HVb1BQ==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=localhost.localdomain) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xTwo7-008QkQ-2f; Thu, 19 Nov 2026 08:48:13 +0100 From: Mirian Shilakadze To: khorenko@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Thu, 19 Nov 2026 11:48:04 +0400 Message-ID: <20261119074808.478064-3-mirian.shilakadze@virtuozzo.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119074808.478064-1-mirian.shilakadze@virtuozzo.com> References: <20261119074808.478064-1-mirian.shilakadze@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 2/3] selftests/ve: move ve_devcg_bpf into ve/ and reuse ve_selftest.h X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org ve_devcg_bpf lives in its own selftests directory and carries private copies of the helpers that ve_selftest.h provides: a mount_cg2_fd of its own, which creates the optionless cgroup2 mount the previous commit stopped the shared header from creating, write_file_at, enter_cgroup, the free ctid search and VE cgroup creation, the CLONE_NEWVE fallback, the ctid range and the controller set a VE cgroup needs enabled. Move the test into tools/testing/selftests/ve/, include ve_selftest.h and drop the local copies. The fixture takes its cgroup2 fd from open_cg2_fd(), creates its VE cgroup with make_ve and removes it with destroy_ve. The vz.slice removal in the teardown stays: the kernel creates that cgroup under the VE root when the container is started, and this test starts one. The TOOLS_INCLUDES flag moves into the ve Makefile with the test, as ve_devcg_bpf_test reads orig_prog_len from the in-tree bpf.h. In kselftest-list.txt the test moves from the ve_devcg_bpf collection to ve. No test logic change. The kernel spec builds ve_devcg_bpf as a target of its own and has to drop it in the same release. Feature: fix selftests https://virtuozzo.atlassian.net/browse/VSTOR-139515 Signed-off-by: Mirian Shilakadze --- tools/testing/selftests/Makefile | 1 - tools/testing/selftests/ve/.gitignore | 1 + tools/testing/selftests/ve/Makefile | 4 + .../{ve_devcg_bpf => ve}/ve_devcg_bpf_test.c | 89 ++----------------- .../testing/selftests/ve_devcg_bpf/.gitignore | 1 - tools/testing/selftests/ve_devcg_bpf/Makefile | 10 --- 6 files changed, 12 insertions(+), 94 deletions(-) rename tools/testing/selftests/{ve_devcg_bpf => ve}/ve_devcg_bpf_test.c (90%) delete mode 100644 tools/testing/selftests/ve_devcg_bpf/.gitignore delete mode 100644 tools/testing/selftests/ve_devcg_bpf/Makefile diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 8ec0ba2deb62..9f820344c16c 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -119,7 +119,6 @@ TARGETS += user_events TARGETS += vDSO TARGETS += ve TARGETS += ve_printk -TARGETS += ve_devcg_bpf TARGETS += mm TARGETS += vfio TARGETS += x86 diff --git a/tools/testing/selftests/ve/.gitignore b/tools/testing/selftests/ve/.gitignore index a468ef980e28..9b1a8911b4cf 100644 --- a/tools/testing/selftests/ve/.gitignore +++ b/tools/testing/selftests/ve/.gitignore @@ -7,3 +7,4 @@ ve_numa_migrate_test ve_aio_ring_test ve_numa_syscalls_prohibited_test ve_tmpfs_mpol_test +ve_devcg_bpf_test diff --git a/tools/testing/selftests/ve/Makefile b/tools/testing/selftests/ve/Makefile index fa4f858227e5..3f47e34cbb18 100644 --- a/tools/testing/selftests/ve/Makefile +++ b/tools/testing/selftests/ve/Makefile @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for ve selftests. CFLAGS += -g -Wall -O2 $(KHDR_INCLUDES) +# orig_prog_len/orig_prog_insns may be newer than the system UAPI headers, so +# build against the in-tree copy under tools/include/uapi. +CFLAGS += $(TOOLS_INCLUDES) TEST_GEN_PROGS += ve_ns_owner_test TEST_GEN_PROGS += ve_perms_test @@ -10,6 +13,7 @@ TEST_GEN_PROGS += ve_numa_migrate_test TEST_GEN_PROGS += ve_aio_ring_test TEST_GEN_PROGS += ve_numa_syscalls_prohibited_test TEST_GEN_PROGS += ve_tmpfs_mpol_test +TEST_GEN_PROGS += ve_devcg_bpf_test # CPUID faulting is x86-64 only. ARCH says "x86" for 32-bit too and lib.mk # picks the clang target by its emptiness, so decide by the compiler. diff --git a/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c b/tools/testing/selftests/ve/ve_devcg_bpf_test.c similarity index 90% rename from tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c rename to tools/testing/selftests/ve/ve_devcg_bpf_test.c index cca0f6905d8d..4027754ace34 100644 --- a/tools/testing/selftests/ve_devcg_bpf/ve_devcg_bpf_test.c +++ b/tools/testing/selftests/ve/ve_devcg_bpf_test.c @@ -35,13 +35,7 @@ #include #include "../kselftest_harness.h" - -#define CTID_MIN 108 -#define CTID_MAX 200 - -#ifndef CLONE_NEWVE -#define CLONE_NEWVE 0x00000040 -#endif +#include "ve_selftest.h" #ifndef VE_FEATURE_BPF #define VE_FEATURE_SYSFS (1ULL << 0) /* deprecated */ @@ -74,20 +68,6 @@ #endif -static int write_file_at(int dirfd, const char *path, const char *val) -{ - int fd, ret; - size_t len = strlen(val); - - fd = openat(dirfd, path, O_WRONLY); - if (fd < 0) - return -1; - - ret = write(fd, val, len); - close(fd); - return (ret == len) ? 0 : -1; -} - enum { TEST_PROG_LOAD, TEST_PROG_LOAD_DENIED, @@ -132,25 +112,6 @@ static int load_devcg_prog(void) return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)); } -static int mount_cg2_fd(void) -{ - int fs_fd, mnt_fd; - - fs_fd = syscall(__NR_fsopen, "cgroup2", 0); - if (fs_fd < 0) - return -1; - - if (syscall(__NR_fsconfig, fs_fd, FSCONFIG_CMD_CREATE, - NULL, NULL, 0) < 0) { - close(fs_fd); - return -1; - } - - mnt_fd = syscall(__NR_fsmount, fs_fd, 0, 0); - close(fs_fd); - return mnt_fd; -} - static int test_prog_load(void) { int fd; @@ -524,30 +485,6 @@ int child_func(void *arg) return ret; } -int enter_cgroup(int cgv2_fd, int ctid) -{ - char cg_path[64]; - char pid_str[64]; - int fd; - int ret; - - if (ctid) - snprintf(cg_path, sizeof(cg_path), "%d/cgroup.procs", ctid); - else - snprintf(cg_path, sizeof(cg_path), "cgroup.procs"); - fd = openat(cgv2_fd, cg_path, O_WRONLY); - if (fd < 0) - return -1; - - snprintf(pid_str, sizeof(pid_str), "%d", getpid()); - ret = write(fd, pid_str, strlen(pid_str)); - if (ret < 0 || ret != strlen(pid_str)) - ret = -1; - - close(fd); - return ret; -} - int run_vzct(struct __test_metadata *_metadata, int cgv2_fd, int ctid, int testid) { @@ -592,11 +529,11 @@ FIXTURE_SETUP(ve_devcg_bpf) char ctid_str[16]; char path[64]; - self->cgv2_fd = mount_cg2_fd(); + self->cgv2_fd = open_cg2_fd(); ASSERT_GE(self->cgv2_fd, 0); ASSERT_EQ(write_file_at(self->cgv2_fd, "cgroup.subtree_control", - "+cpuset +cpu +cpuacct +io +memory +hugetlb +pids +rdma +misc +ve"), 0); + VE_CONTROLLERS), 0); ASSERT_EQ(write_file_at(self->cgv2_fd, "ve.default_sysfs_permissions", "/ rx"), 0); @@ -605,21 +542,10 @@ FIXTURE_SETUP(ve_devcg_bpf) ASSERT_EQ(write_file_at(self->cgv2_fd, "ve.default_sysfs_permissions", "fs/cgroup rw"), 0); - self->ctid = CTID_MIN; - while (self->ctid < CTID_MAX) { - snprintf(ctid_str, sizeof(ctid_str), "%d", self->ctid); - if (faccessat(self->cgv2_fd, ctid_str, F_OK, 0) != 0 && - errno == ENOENT) - break; - self->ctid++; - } - ASSERT_LT(self->ctid, CTID_MAX); - - ASSERT_EQ(mkdirat(self->cgv2_fd, ctid_str, 0755), 0); - - snprintf(path, sizeof(path), "%d/cgroup.controllers_hidden", self->ctid); - ASSERT_EQ(write_file_at(self->cgv2_fd, path, "-ve"), 0); + self->ctid = make_ve(self->cgv2_fd, CTID_MIN); + ASSERT_GE(self->ctid, 0); + snprintf(ctid_str, sizeof(ctid_str), "%d", self->ctid); snprintf(path, sizeof(path), "%d/ve.veid", self->ctid); ASSERT_EQ(write_file_at(self->cgv2_fd, path, ctid_str), 0); }; @@ -630,8 +556,7 @@ FIXTURE_TEARDOWN(ve_devcg_bpf) snprintf(path, sizeof(path), "%d/vz.slice", self->ctid); unlinkat(self->cgv2_fd, path, AT_REMOVEDIR); - snprintf(path, sizeof(path), "%d", self->ctid); - unlinkat(self->cgv2_fd, path, AT_REMOVEDIR); + destroy_ve(self->cgv2_fd, self->ctid); close(self->cgv2_fd); } diff --git a/tools/testing/selftests/ve_devcg_bpf/.gitignore b/tools/testing/selftests/ve_devcg_bpf/.gitignore deleted file mode 100644 index a1f032ce2428..000000000000 --- a/tools/testing/selftests/ve_devcg_bpf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ve_devcg_bpf_test diff --git a/tools/testing/selftests/ve_devcg_bpf/Makefile b/tools/testing/selftests/ve_devcg_bpf/Makefile deleted file mode 100644 index ba811f22e36a..000000000000 --- a/tools/testing/selftests/ve_devcg_bpf/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Makefile for ve_devcg_bpf selftests. -CFLAGS += -g -Wall -O2 -# orig_prog_len/orig_prog_insns may be newer than the system UAPI headers, so -# build against the in-tree copy under tools/include/uapi. -CFLAGS += $(TOOLS_INCLUDES) - -TEST_GEN_PROGS += ve_devcg_bpf_test - -include ../lib.mk -- 2.47.3 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel