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 at 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 root at 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? LIBVIRT xml used to spawn LXC ubuntu 21.04 container: <domain type='lxc'> <name>host</name> <uuid>096f46bf-80bb-4441-a512-043a9c7a64d4</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static' cpuset='7'>1</vcpu> <os> <type arch='x86_64'>exe</type> <init>/sbin/init</init> </os> <features> <capabilities policy='allow'> <audit_control state='on'/> <audit_write state='on'/> <block_suspend state='on'/> <chown state='on'/> <ipc_lock state='on'/> <ipc_owner state='on'/> <kill state='on'/> <mac_admin state='on'/> <mac_override state='on'/> <mknod state='on'/> <net_admin state='on'/> <net_bind_service state='on'/> <net_broadcast state='on'/> <net_raw state='on'/> <sys_admin state='on'/> <sys_boot state='on'/> <sys_ptrace state='on'/> <sys_rawio state='on'/> <sys_resource state='on'/> <sys_time state='on'/> <syslog state='on'/> </capabilities> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>destroy</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/lib64/libvirt/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/junos/lxc/jdm/jdm1/rootfs'/> <target dir='/'/> </filesystem> </devices> </domain> Thanks, Yuvaraj. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20210804/ecc7d223/attachment.htm>
Michal Prívozník
2021-Aug-05 09:33 UTC
Usage of virsh commands on guest lxc container are failing
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 at 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 directoryThis 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 at 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: https://libvirt.org/uri.html 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. Michal