OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH vz10 1/6] ve: tell ve_setup_task() which VE the task comes from
Date: Mon, 16 Nov 2026 14:45:44 +0400	[thread overview]
Message-ID: <20261116104552.102938-2-mirian.shilakadze@virtuozzo.com> (raw)
In-Reply-To: <20261116104552.102938-1-mirian.shilakadze@virtuozzo.com>

The next changes mark a task entering a VE by where it comes from. Pass
the VE the task leaves to ve_setup_task(). No functional change.

Feature: ve: ve generic structures
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 include/linux/ve.h       | 6 ++++--
 kernel/ve/ve.c           | 3 ++-
 kernel/ve/ve_namespace.c | 7 +++++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index a400d21593b2..2fe1a1c9ff55 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -282,7 +282,8 @@ int ve_net_hide_sysctl(struct net *net);
 
 extern bool is_ve_init_net(const struct net *net);
 
-void ve_setup_task(struct task_struct *p, struct ve_struct *ve);
+void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
+		   struct ve_struct *ve);
 
 void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool));
 
@@ -390,7 +391,8 @@ static inline struct cgroup_subsys_state *css_ve_root1(
 static inline int vz_security_family_check(struct net *net, int family, int type) { return 0; }
 static inline int vz_security_protocol_check(struct net *net, int protocol) { return 0; }
 
-static inline void ve_setup_task(struct task_struct *p, struct ve_struct *ve) { }
+static inline void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
+				 struct ve_struct *ve) { }
 
 static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { }
 
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 6cdfaaa4e703..29d68594bcde 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1841,7 +1841,8 @@ int ve_get_cpu_stat(struct ve_struct *ve, struct kernel_cpustat *kstat)
 }
 EXPORT_SYMBOL(ve_get_cpu_stat);
 
-void ve_setup_task(struct task_struct *task, struct ve_struct *ve)
+void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve,
+		   struct ve_struct *ve)
 {
 	if (ve == &ve0)
 		return;
diff --git a/kernel/ve/ve_namespace.c b/kernel/ve/ve_namespace.c
index 6b12bcd605ea..82b84ed93092 100644
--- a/kernel/ve/ve_namespace.c
+++ b/kernel/ve/ve_namespace.c
@@ -106,6 +106,7 @@ int copy_ve_ns(unsigned long flags, struct task_struct *p)
 {
 	struct user_namespace *user_ns = task_cred_xxx(p, user_ns);
 	struct ve_namespace *old_ve_ns = p->ve_ns;
+	struct ve_struct *old_ve = p->task_ve;
 	struct ve_namespace *new_ve_ns;
 
 	if (!(flags & CLONE_NEWVE)) {
@@ -123,7 +124,7 @@ int copy_ve_ns(unsigned long flags, struct task_struct *p)
 	p->ve_ns = new_ve_ns;
 	p->task_ve = new_ve_ns->ve;
 
-	ve_setup_task(p, p->task_ve);
+	ve_setup_task(p, old_ve, p->task_ve);
 
 	return 0;
 }
@@ -161,6 +162,7 @@ void free_ve_ns(struct ve_namespace *ns)
 void switch_ve_namespace(struct task_struct *p, struct ve_namespace *new)
 {
 	struct ve_namespace *old;
+	struct ve_struct *old_ve;
 
 	/*
 	 * FIXME
@@ -170,6 +172,7 @@ void switch_ve_namespace(struct task_struct *p, struct ve_namespace *new)
 
 	scoped_guard(task_lock, p) {
 		old = p->ve_ns;
+		old_ve = p->task_ve;
 		p->ve_ns = new;
 		p->task_ve = new ? new->ve : &ve0;
 	}
@@ -177,7 +180,7 @@ void switch_ve_namespace(struct task_struct *p, struct ve_namespace *new)
 	if (old)
 		put_ve_ns(old);
 
-	ve_setup_task(p, p->task_ve);
+	ve_setup_task(p, old_ve, p->task_ve);
 }
 
 void exit_ve_namespace(struct task_struct *p)
-- 
2.43.0

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

  reply	other threads:[~2026-11-16 10:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:45 [Devel] [PATCH vz10 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
2026-11-16 10:45 ` Mirian Shilakadze [this message]
2026-11-16 10:50   ` [Devel] [PATCH vz10 1/6] ve: tell ve_setup_task() which VE the task comes from no-reply
2026-11-16 10:45 ` [Devel] [PATCH vz10 2/6] ve: hide only the tasks the host sends into a VE Mirian Shilakadze
2026-11-16 10:50   ` no-reply
2026-11-16 17:17   ` Konstantin Khorenko
2026-11-16 10:45 ` [Devel] [PATCH vz10 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
2026-11-16 10:55   ` no-reply
2026-11-16 17:17   ` Konstantin Khorenko
2026-11-16 10:45 ` [Devel] [PATCH vz10 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks Mirian Shilakadze
2026-11-16 10:53   ` no-reply
2026-11-16 17:17   ` Konstantin Khorenko
2026-11-16 10:45 ` [Devel] [PATCH vz10 5/6] fs: give the mount relaxations of a pseudosuper VE " Mirian Shilakadze
2026-11-16 10:56   ` no-reply
2026-11-16 17:17   ` Konstantin Khorenko
2026-11-16 10:45 ` [Devel] [PATCH vz10 6/6] ve: give the remaining pseudosuper relaxations " Mirian Shilakadze
2026-11-16 10:56   ` no-reply
2026-11-16 17:17   ` Konstantin Khorenko
2026-11-16 17:17 ` [Devel] [PATCH vz10 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Konstantin Khorenko
2026-11-17 10:21   ` Mirian Shilakadze

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=20261116104552.102938-2-mirian.shilakadze@virtuozzo.com \
    --to=mirian.shilakadze@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@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