[libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?
Daniel P. Berrange
berrange at redhat.com
Wed Jan 22 10:31:35 UTC 2014
On Wed, Jan 22, 2014 at 05:35:27PM +0800, Gao feng wrote:
> On 01/21/2014 01:59 AM, Daniel P. Berrange wrote:
> > On Mon, Jan 20, 2014 at 06:53:28PM +0100, Thierry Parmentelat wrote:
> >> Hi
> >> Well if I need to run anything in the container context, short of entering
> >> it through e.g. ssh - hoping this is properly set up - well, I can’t..
> >> I am using libvirt / lxc to set up a build box; essentially every night
> >> I would spawn a set of fresh VMs of some flavours (fedora18, ubuntu,
> >> what not) and use this to rebuild my system from scratch
> >> In this context it’s a real hassle to have to even set up ssh, there is
> >> no good reason for the build VM to run an ssh service at all, and I am
> >> concerned it might pull dependencies that I do not need/want
> >> I’d much rather have a direct means to just run some command inside the container.
> >> Admittedly I’m brain-damaged after having used vservers for too long, and their
> >> ‘vserver <container> exec command to run’ feature is in my genes now ;)
> >> Now maybe I am the one who is missing something and there already is something to do that ?
> >> Using the trick below I essentially have what I need mind you, I’m just concerned that it
> >> kind of works by accident :-)
> > Yes, it already exists, albeit as a lxc specific custom command/api:
> > $ virsh lxc-enter-namespace $CONTAINER /path/to/command/to/run arg1 arg2...
> > There's a corresponding API in the libvirt-lxc.so library
> > virDomainLxcEnterNamspace
> > Eventually we'll turn this into a proper libvirt API with a less sucky
> > virsh command name.
> Sorry for another question, lxc-enter-namespace is unavailable on the remote machine,
> you can't use virsh -c lxc+ssh://email@example.com/ lxc-enter-namespace $CONTAINER /path/to/command/to/run arg1 arg2.
> I want to know what's the major handicap that we cannot support lxc-enter-namespace on
> remote machine.
That's just the way this command is designed to work. It uses setns() to
directly move the command into the namespace, while preserving all aspects
of its environment such as stdio/env variables/etc.
If we wanted to make it work remotely, we'd have to setup some kind of
I/O tunnelling, in which case you start to loose functionality - such
as proper handling of terminal features like SIGWINCH
That all said, I would like to see some kind of "execute" command in the
libvirt API that worked remotely, albeit with some restrictions on its
features as compared to lxc-enter-namespace.
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list