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. As a work-around if I use the "lxc-create -t <OS> -n <name>" command followed by "conn.domainDefineXML(xml_config)", I can view the domain within "lxc-ls --fancy" Any one has observed this problem earlier and is there a way I can create the domain without using "lxc-create ..." command and still list the domain on the "lxc-ls --fancy" list? Thank you, Anu
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
Thanks for the explanation Jiri! On Thu, Jun 4, 2015 at 11:43 PM, Jiri Denemark <jdenemar@redhat.com> wrote:> 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 >-- Kind Regards, Anu Mercian Summer Intern-ESnet