[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?



Hello there

I am trying to locate the namespaces in place for a given lxc container (specifically /proc/<pid>/ns/*)

And to this end I was wondering what is the recommended way to probe for an lxc container's init pid
(mostly I'm after the mnt and pid namespaces, and probably network ones, but the actual list probably should not matter) 

I've found about "virsh domid" but this gives me the pid for libvirt_lxc, which turns out to have unmodified namespaces (at least as far as the mnt ns)
OTOH this process has exactly one child which is the container's init, which seems to have the right set of namespaces 

My angle right now is to look in /proc/<domid_pid>/task/children for a - hopefully single - pid and that seems to work for now, but I am concerned this code may be fragile so I would rather use a more robust approach; or maybe this is robust ? 

Any insight would be most welcome -- Thanks in advance

---
PS.
I am using a stock fedora20 box with 
[root vnode11 ~]# rpm -q libvirt
libvirt-1.1.3.2-1.fc20.x86_64




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]