Re: What is the robust/recommended way to retrieve the PID of a VM's init process ?

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

 



Hi again

So I did give this interesting lxc-enter-namespace feature a try 

I found a few glitches that I thought might be of interest; I recall that I use a stock f20 box which probably is already behind as compared to the devel version
root@warhol ~/thierry # rpm -q libvirt
libvirt-1.1.3.2-1.fc20.x86_64

So what I can see is that the exec’ed command seems to have a very limited PATH - if the feature is enabled at all:

# virsh lxc-enter-namespace my-01 -- ls /etc/yum.repos.d/building.repo

# virsh lxc-enter-namespace my-01 -- /usr/bin/ls /etc/yum.repos.d/building.repo
/etc/yum.repos.d/building.repo

So my comments are, 
- first that defining some even minimal PATH would help;
- 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 ? 

—
In the same conditions our own local tool would do this

# lxcsu -ro my-01 -- ls /etc/yum.repos.d/building.repo
/etc/yum.repos.d/building.repo

Hope this helps — Thierry

On 20 Jan 2014, at 19:03, Thierry Parmentelat <thierry.parmentelat@xxxxxxxx> wrote:

> Oh, I had totally failed to spot that one..
> Thanks for the tip, I’ll give this a try :-)
> 
> On 20 Jan 2014, at 18:59, Daniel P. Berrange <berrange@xxxxxxxxxx> 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.
>> 
>> Daniel
>> -- 
>> |: 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 :|
> 


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]