[libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?
thierry.parmentelat at inria.fr
Thu Jan 23 17:48:33 UTC 2014
>> So I did give this interesting lxc-enter-namespace feature a try
> Thank you.
This is great, it solves my initial problem quite nicely, and I have given up on using my own tool :-)
>> So my comments are,
>> - first that defining some even minimal PATH would help;
> PATH relative to the container? Yes, that might be a nice addition;
> would you like to propose the means of passing that information through
> to the child?
Maybe I can describe my needs a little bit more
Typically I need to run ‘make’ in the guest as part of its ‘preparation’ before I hand it over to users
Unfortunately not all guests have the ‘make’ binary at the same location - esp. with the recent usrmove business…
Actually what I am doing right now is to let bash handle that with
virsh lxc-enter-namespace container /bin/bash -c “make -C /build”
which fits my needs to not have to decide where make might sit
This seems to work fine, although I am not sure to have covered all the corner cases yet
This being said, this is fine as long as I use that in scripts, but having to do this in everyday life would be a hassle
I am not sure that I see any good reason not to just call ‘execvp’ instead of ‘execv’ in cmdLxcEnterNamespace
It is true that the PATH as set in the host might not be the best setting for the guest, but it could serve as a decent approximation for a daily usage
>> - and second that in this first form, it would be great if virsh could write some error on stderr instead of being almost totally silent, it took me some time to figure that it kind of worked
>> Does this mean we would lose any message sent on stderr ?
> No, stderr is preserved. But I have patches awaiting review that make
> the process nicer, including informing you of any non-zero exit status
> of the executed command:
This change would have been welcome during my very first attempt :-)
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
More information about the libvir-list