[libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?
thierry.parmentelat at inria.fr
Mon Jan 20 10:38:08 UTC 2014
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
I am using a stock fedora20 box with
[root at vnode11 ~]# rpm -q libvirt
More information about the libvir-list