Re: Usage of virsh commands on guest lxc container are failing

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


On 8/4/21 8:51 AM, Yuva Raj wrote:
> Hi Team,
> I am new to the Qemu/KVM, libvirt and these technologies.
> Hypervisor is running on linux kernel with libvirtd version 1.3.2.
> I am trying to spawn LXC ubuntu(21.04) container using virsh -c lxc://
> commands on the hypervisor and ubuntu container is running now.
> On the ubuntu 21.04 container, I have installed debian "libvirt-clients"
> package to use the virsh utility.
> Updated the /etc/libvirt/libvirt.conf with to the hypervisor Qemu URI.
> When I run virsh commands without URI, observing below error
> root@host:~# virsh list
> error: failed to connect to the hypervisor
> error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such
> file or directory

This means that you have no daemon running, which is not surprising
because IIUC you are running virsh from within the container and it's
not configured to share /var/run/libvirt with the host.

> root@host:~# virsh -c <Qemu URI> list
>  Id   Name      State
> -------------------------
> 2      VM        running
> If I execute the virsh commands without "-c" option, then ubuntu 21.04
> container would display the VM's running as same as hypervisor.
> Could you please help to manage this on the LXC ubuntu container?

So the problem is that plain virsh without any -c argument doesn't
connect to LXC driver? By default, virsh uses UNIX sockets to connect to
daemon. This can be overridden and another transport layer can be used
(e.g. TCP), it's documented here:

For UNIX sockets to work you will need to share the directory with UNIX
sockets between container and the host. Alternatively, you can try some
other transport.


[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux