Usage of virsh commands on guest lxc container are failing

Yuva Raj yuvaraj301294 at gmail.com
Wed Aug 4 06:51:59 UTC 2021


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>


More information about the libvirt-users mailing list