[libvirt-users] LXCs using Libvirt

Jiri Denemark jdenemar at redhat.com
Fri Jun 5 06:43:45 UTC 2015


On Thu, Jun 04, 2015 at 16:22:43 -0700, Anu Mercian wrote:
> Hi all,
> 
> I am trying to bring up lxc's using Libvirt JAVA API. I do the following:
> 
> conn = Connect("lxc:\\\")
> 
> xml_config = "<domain> .... <\domain>"
> 
> dom = conn.domainCreateXML(xml_config, 0)
> 
> dom.create()
> 
> Using the above code, I am able to start a domain but the domain is not
> visible within the "lxc" list, i.e
> when I use the command "lxc-ls --fancy", the domain that was created cannot
> be viewed, although, when I use the function conn.listDomains(), I can view
> the domain.

That's expected and correct. Libvirt does not use lxc tools to manage
Linux containers. Libvirt manages everything by itself and talks to the
kernel directly. Thus containers created in libvirt are not visible to
lxc tools and containers created using lxc tools are not visible to
libvirt. In other words, use either lxc tools or libvirt but do not try
to mix them.

If you want to manage libvirt's containers from a command line, use
virsh. For example, "virsh list --all" will show you all containers
libvirt knows about.

Jirka




More information about the libvirt-users mailing list