[libvirt-users] How to run a cmd inside lxc through libvirt API?

Daniel P. Berrange berrange at redhat.com
Fri Feb 22 09:53:49 UTC 2013

On Fri, Feb 22, 2013 at 09:27:05AM +0000, 张章 wrote:
> Hi
> As far as I know, I can not run a cmd inside lxc through
> shell after "virsh -c lxc:/// console". How could I run
> a cmd though libvirt API instead of shell like the userspace
> tool lxc_start(name, cmd, conf)? 

Latest libvirt has a new command for running stuff inside a container

   virsh -c lxc:/// lxc-enter-namespace mycontainername -- /bin/ps -auxf

This requires a fairly new kernel(3.7 or even 3.8 kernel is preferred)
since it needs all 6 namespaces present in /proc/self/ns to work properly.

|: 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 libvirt-users mailing list