[Users] reliably detect wether hardware_node, openvz_host or openvz_instance

Stanichenko Marat mstanichenko at openvz.org
Wed Jul 30 07:36:13 EDT 2008


Hello,

the patch was sent but the status of that bug didn't change. I've 
attached the patch that you can use. It fixes the problem.

Stanichenko Marat

neerd пишет:
> Hello,
>
> Parsing the /proc/self/status does not work with 2.6.24-ovz005 kernel. 
> In fact the openvz_host still shows the "EnvID: 0" but there is no 
> more "EnvID" into the vz instances. I reported it as a bug here: 
> http://bugzilla.openvz.org/show_bug.cgi?id=936 but with no more 
> informations since.
>
> I'm using the following code to see if I am in an openvz instance:
> -----
> tail -n 1 /proc/vz/veinfo | grep -qs '^[[:space:]]*[1-9]'
> -----
>
> I use it because openvz instances can not acces hardware where openvz 
> hosts and pure hardware nodes can.
>
> Jerome
>
>
-------------- next part --------------
Allow envID fields in /proc/self/status in VE. Also allow get VPid,
PNState, StopState, etc.

OpenVZ Bug #936
http://bugzilla.openvz.org/show_bug.cgi?id=936

Signed-off-by: Vitaliy Gusev <vgusev at openvz.org>

---
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 871badb..25f2d73 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -208,16 +208,15 @@ static inline char *task_state(struct task_struct *p, char *buffer)
 	buffer += sprintf(buffer, "\n");
 
 #ifdef CONFIG_VE
-	if (ve_is_super(get_exec_env()))
-		buffer += sprintf(buffer,
-				"envID:\t%d\n"
-				"VPid:\t%d\n"
-				"PNState:\t%u\n"
-				"StopState:\t%u\n",
-				p->ve_task_info.owner_env->veid,
-				task_pid_vnr(p),
-				p->pn_state,
-				p->stopped_state);
+	buffer += sprintf(buffer,
+			  "envID:\t%d\n"
+			  "VPid:\t%d\n"
+			  "PNState:\t%u\n"
+			  "StopState:\t%u\n",
+			  p->ve_task_info.owner_env->veid,
+			  task_pid_vnr(p),
+			  p->pn_state,
+			  p->stopped_state);
 #endif
 	return buffer;
 }


More information about the Users mailing list