Thanks for the reply. 

Does libvirt have corresponding API for this? 

regards
zhangzhang

> Date: Fri, 22 Feb 2013 09:53:49 +0000
> From: berrange@redhat.com
> To: zhang_zhang@live.com
> CC: libvirt-users@redhat.com
> Subject: Re: [libvirt-users] How to run a cmd inside lxc through libvirt API?
>
> 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.
>
> Regards,
> 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 :|