From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 154138015D for ; Wed, 9 Sep 2026 14:35:18 +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 689EXwww020401; Wed, 9 Sep 2026 17:33:59 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 689EXwww020401 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="KpsMYpuF" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 689EXvm7020390 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 9 Sep 2026 17:33:57 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 689EXvm7020390 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48589603501so3669261f8f.3 for ; Wed, 09 Sep 2026 07:33:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBwInSZCh1JtZEviQh1kTt1Z2dzql7cNNL4Y+hrs/fGS4YWOijqrhUcIvGuNBrFmotxDBLbmag==@openvz.org X-Gm-Message-State: AFuF++m0jdVCMp6IXgbJaISwQOaCfEiPwLTIao+Hi2zBnPUyMh7RBsuP +Tw5mq8af7jGnerLShdGExgod1p27kuvm/hbmnad0A+pLpvesGorCuCzI7hOQ6e4sMXpuh9YFvQ 6QiDED6WWK6UjdKnSUXMTn4dRshU6gb+ljFyE2ZuRORF2L4jhU6JpGw== X-Gm-Gg: AYBFou2gsU8IgmZFy8RP6YvW6qH+36ful3FxhUEJ9emXG/zX0lHD2ctm4tnLtsyG09L wJdqmMROp87bVZ8ZMCKPVyWg2xdqlZv7TeTYB4g3a4QKauVT/0fwOQ2O60PhSPKd+vNYvIH6OuV Z3euz1dBtxLIzLA9AG9xkdNxOZyyuWgaB2VY6zuCVletCeQJ5xKOGZj1QSoNsor2Mc3qblwCb1F xCcDsg+LA9I7Sft+oyoGckMrTViPHIHBiBp+gGURwCUK6aOZBFFXg5jGJsUnG0spw4q+A1e/hzx /PCTvDlRApjtJ1hrQAYqoltSofoXUR7L0FhsA5KOrJVUxFQaxnzvb801EhOYdjQbCa6colnsSj4 UAFsV9fqBvKw1lBls3Gtrre0WJn1+V4g= X-Received: by 2002:a05:6000:18a9:b0:485:9211:6560 with SMTP id ffacd0b85a97d-485921165d7mr31870961f8f.25.1788964436963; Wed, 09 Sep 2026 07:33:56 -0700 (PDT) X-Received: by 2002:a05:6000:18a9:b0:485:9211:6560 with SMTP id ffacd0b85a97d-485921165d7mr31870888f8f.25.1788964436454; Wed, 09 Sep 2026 07:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1788964436; cv=none; d=google.com; s=arc-20260327; b=eZYp9w3bv2rXL68t/Pmi+o15hbEgGGIts2YKf3GY7lXiUZT5ncDJbCZEspNHPjbGgo gkyQm1iO90MuyJfPMf2k8yi7mlyx3v18u3mnvOqVSGykWshdiiU7bBjXzOLLxmEQs+Mz ogYALqBfm5wLg+VR+6GOUXI4g3USd5BQlt4iD5WS8MK9TnbvLc04a3UVkiJpGi1jsqej PgHqfiJbpi+F9cl5xNjp0v6gJQuUgwLfqhEeuMWJr3bcf8CEQ9wh262Tuj+zwLlAX/l0 2h065u1CLYmfQT079ScyqJSimB+gsfUDuyUolqYCCozp9h55A5aA2QMuuYcgM5NUILCA XbnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:mime-version:dkim-signature; bh=OF3VET4wPfNSZN5v+by3mgQWqRs4bAc8DAGlHOiDJ9U=; fh=8+X+w90mdJ6G1WJJJxch/JQtL3s0QC+l1k0I7SQJzmc=; b=lp3bc9d8UgKVKXthgrSkL/X1ayvv8aotK+oYFnO8X5hSHF/KEnxQ6EsS2EJrAaMhdU xeyME+ELBSaFbC1wROIYh39x1gQQ41rHzIpuAX8jadPg1torl726UCjwk2yhcgK/CIq0 w3z2VXd6ZQs7JafBDSaMfMbkqmZ6Gbk65AqWOcHN1Plt79Vq8VUjFqIUdFGWSBFrGtEt NwZRzVCHkuyObvxjiVDw7XVxGL7dO9F/13BOP3PbQKgBct27nJsr4M+kQhsFNGdmie0P JQG7m0FBjBhQdZXcBgfDLxpdauW02Cxz1kASsSSFndzU3/o7BZk9ulSeRU74oBzF6/ei gDeQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=KpsMYpuF; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@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-485883c6a1esi33323051f8f.147.2026.09.09.07.33.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 07:33:56 -0700 (PDT) Received-SPF: pass (google.com: domain of vasileios.almpanis@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=KpsMYpuF; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@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=Message-Id:Date:From:Subject:Content-Type: MIME-Version; bh=OF3VET4wPfNSZN5v+by3mgQWqRs4bAc8DAGlHOiDJ9U=; b=KpsMYpuFXTob xdIw1l658Cl+SKVKnpsmR8KbtY2/GiUJT/IKcUkcXlz7JV1nO2BN+/yJbRnlwtFG9b0HjFUmAqrbJ O1nEpSIKWg+R0F4ccKXdx4THGfuHNkCu1170vVe42Q/mfWY6Ip5c+XhOM8gfGvz3gRsE509dZvp+O I9pATqO/e3kokFdOc2LV3e0wSiLxgvA5aeGc4J70cgkDdGzHQDZz4mmj8UiVLn5+oPmq1YHQp9XuN r4xIPAyTmZchEtV7jgZk2KND4drd2x56pFaHKSEwu5w5Vr38BCSRfbhNmsFNGmPm7gyMRJ4Zmj/46 UzkkwxN/31qrIzlucW7nmQ==; Received: from [130.117.225.5] (helo=dev010.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1x4JKV-005BC3-2V; Wed, 09 Sep 2026 16:33:54 +0200 MIME-Version: 1.0 From: Vasileios Almpanis To: Vladimir Riabchun In-Reply-To: <20260909-ve-selftest-improv-v2-2-aad0a25d6569@virtuozzo.com> References: <20260909-ve-selftest-improv-v2-0-aad0a25d6569@virtuozzo.com> <20260909-ve-selftest-improv-v2-2-aad0a25d6569@virtuozzo.com> Date: Wed, 09 Sep 2026 14:33:53 +0000 Message-Id: <178896443372.479408.12192911474785454186.b4-review@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788964435; l=2555; i=vasileios.almpanis@virtuozzo.com; s=20260812; h=from:subject:message-id; bh=C+YGz1bWWTZs2xRWijTbcZEBUoS0UN3Da8IgS/HOEnE=; b=RVBMK1q3sccK2IYP6cX78ZDWr37UDYdHhwI74yynZy8ivIqt5sm8E/mkYb09OYKkgFpSZGERb 172qNqMDbx2ArlpwutWvlK6RlDkpoVF1p6vKmkLIb81+ZR+BsThYj7x X-Developer-Key: i=vasileios.almpanis@virtuozzo.com; a=ed25519; pk=HhuHDXAcPva9A8zccWEMRsb36reu+y4IVbBjXKxNUjw= X-OZ-Fwd: true Cc: devel@openvz.org Subject: Re: [Devel] [PATCH VZ10 v2 2/3] selftests/ve: Add more helpers 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 > Some more read/write helpers may be useful. > > Also, add a helper to execute functions in child process with > switched namespaces and cgroup. > > https://virtuozzo.atlassian.net/browse/VSTOR-144504 > > Feature: ve selftests > Signed-off-by: Vladimir Riabchun > > diff --git a/tools/testing/selftests/ve/ve_selftest.h b/tools/testing/selftests/ve/ve_selftest.h > index ee960f7db0b4..e88293a39d34 100644 > --- a/tools/testing/selftests/ve/ve_selftest.h > +++ b/tools/testing/selftests/ve/ve_selftest.h > @@ -168,6 +168,14 @@ static inline int write_file_at(int dirfd, const char *path, const char *val) > return (ret == (int)len) ? 0 : -1; > } > > +static inline int write_u64_at(int dirfd, const char *path, unsigned long long val) > +{ > + char s[32]; > + > + snprintf(s, sizeof(s), "%llu", val); > + return write_file_at(dirfd, path, s); > +} > + > static inline int read_file_at(int dirfd, const char *path, char *buf, > size_t buflen) > { > @@ -198,14 +206,9 @@ static inline int read_u64_at(int dirfd, const char *path, > unsigned long long *out) > { > char buf[32] = {0}, *end; > - int fd, ret; > - > - fd = openat(dirfd, path, O_RDONLY); > - if (fd < 0) > - return -1; > + int ret; > > - ret = read(fd, buf, sizeof(buf) - 1); > - close(fd); > + ret = read_file_at(dirfd, path, buf, sizeof(buf)); > if (ret <= 0) > return -1; > > @@ -216,6 +219,25 @@ static inline int read_u64_at(int dirfd, const char *path, > return 0; > } > > +static inline int read_s32_at(int dirfd, const char *path, > + int *out) > +{ > + char buf[32] = {0}, *end; > + long tmp; > + int ret; > + > + ret = read_file_at(dirfd, path, buf, sizeof(buf)); > + if (ret <= 0) > + return -1; > + > + errno = 0; > + tmp = strtol(buf, &end, 10); > + if (errno || end == buf || tmp < INT_MIN || tmp > INT_MAX) > + return -1; > + *out = tmp; > + return 0; > +} > + > /* A fresh, private cgroup2 mount, returned as an fd to use with *at() calls. */ > static inline int mount_cg2_fd(void) > { > @@ -259,6 +281,55 @@ static inline int enter_cgroup(int cgv2_fd, int ctid) > return ret; > } > > +/* > + * Run function in VE cgroup and new namespaces. > + * > + * Namespaces are provided via unshare_flags. The documentation here is a bit weird. There is no unshare_flags just flags and they are not passed to unshare but to enter_namespaces. -- Vasileios Almpanis _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel