Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am currently trying out the Windows Subsystem for Linux v2, on a Windows 10 Fast Ring build (Build 20161). More specifically, I am trying to run a qemu-kvm virtual machine using nested virtualization, but each attempt at creating a new VM using virt-manager ends up in failure.

I use Ubuntu 18.04 in my WSL2 instance, with a custom built kernel (that includes everything related to virtualization - please see this guide: https://boxofcables.dev/accelerated-kvm-guests-on-wsl-2/ ) and "nestedVirtualization" is set to "true" in my WSL config file. Even more so, "sudo kvm-ok" returns positive results when ran inside the Ubuntu instance.

I do have DBUS installed in Ubuntu WSL, and the service is running, so I believe this is not the source of the problem. I'm using VcXsrv for displaying X11 windows.

Here are the errors I get with each attempt:

Libvirtd.log

2020-07-07 03:33:24.507+0000: 1273: info : libvirt version: 4.0.0, package: 1ubuntu8.17 (Marc Deslauriers <marc.deslauriers@ubuntu.com> Wed, 06 May 2020 14:18:23 -0400)
2020-07-07 03:33:24.507+0000: 1273: info : hostname: LAPTOP-DRAGOS
2020-07-07 03:33:24.507+0000: 1273: error : udevGetDMIData:1818 : internal error: Failed to get udev device for syspath '/sys/devices/virtual/dmi/id' or '/sys/class/dmi/id'
2020-07-07 03:39:16.636+0000: 1261: error : virNetSocketNewConnectUNIX:715 : Failed to connect socket to '/var/run/libvirt/virtlogd-sock': No such file or directory
2020-07-07 03:39:29.617+0000: 1258: error : virNetSocketNewConnectUNIX:715 : Failed to connect socket to '/var/run/libvirt/virtlogd-sock': No such file or directory
2020-07-07 03:39:29.617+0000: 1258: error : virNetSocketNewConnectUNIX:715 : Failed to connect socket to '/var/run/libvirt/virtlogd-sock': No such file or directory
2020-07-07 04:01:14.141+0000: 1257: error : virKeepAliveTimerInternal:143 : internal error: connection closed due to keepalive timeout

Virt-manager GUI (when I click "Begin Installation" once all options have been set):

Unable to complete install: 'Failed to connect socket to '/var/run/libvirt/virtlogd-sock': No such file or directory'
Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 89, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/create.py", line 2553, in _do_async_install
    guest.start_install(meter=meter)
  File "/usr/share/virt-manager/virtinst/guest.py", line 498, in start_install
    doboot, transient)
  File "/usr/share/virt-manager/virtinst/guest.py", line 434, in _create_guest
    domain = self.conn.createXML(install_xml or final_xml, 0)
  File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3603, in createXML
    if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirtError: Failed to connect socket to '/var/run/libvirt/virtlogd-sock': No such file or directory

What am I doing wrong? Any input is highly appreciated! Thanks in advance!

UPDATE: As @FreeSoftwareServers suggested, I tried starting the virtlogd service. Since Ubuntu 18.04 does not use initd, I went for sudo service virtlogd start. And that got me over the initial error, but now I seem to encounter some permission issues, because I get the following:

Unable to complete install: 'internal error: process exited while connecting to monitor: Could not access KVM kernel module: Permission denied
2020-07-08T03:32:26.585442Z qemu-system-x86_64: failed to initialize KVM: Permission denied'
Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 89, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/create.py", line 2553, in _do_async_install
    guest.start_install(meter=meter)
  File "/usr/share/virt-manager/virtinst/guest.py", line 498, in start_install
    doboot, transient)
  File "/usr/share/virt-manager/virtinst/guest.py", line 434, in _create_guest
    domain = self.conn.createXML(install_xml or final_xml, 0)
  File "/usr/lib/python2.7/dist-packages/libvirt.py", line 3603, in createXML
    if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirtError: internal error: process exited while connecting to monitor: Could not access KVM kernel module: Permission denied
2020-07-08T03:32:26.585442Z qemu-system-x86_64: failed to initialize KVM: Permission denied

virt-manager GUI is run with sudo, so this permission denial message seems a bit puzzling.

Best regards, Dragoș

System has not been booted with systemd as init system (PID 1). Can't operate.. However, I did use sudo service virtlogd start and that got rid of the socket error. Now I am stuck in a different place: Unable to complete install: 'internal error: process exited while connecting to monitor: Could not access KVM kernel module: Permission denied 2020-07-08T03:22:55.259796Z qemu-system-x86_64: failed to initialize KVM: Permission denied' – diorgulescu Jul 8, 2020 at 3:26 That is definitely progress! I would post comments like that as an update to your question as code is hard to read in comments. That sounds like permission issues, how did u start VM via CLI or LibVirtMGR? Try using GUI if u used CLI – FreeSoftwareServers Jul 8, 2020 at 3:36 Just updated the question, as suggested. Thanks for the tip! virt-manager is started from the CLI, with sudo. – diorgulescu Jul 8, 2020 at 3:46

On Windows 11, I got this working by fixing up /dev/kvm:

sudo chown root:kvm /dev/kvm
sudo chmod 660 /dev/kvm

Full setup:

# Install virt-manager
sudo apt install -y virt-manager
# Add youself to kvm and libvirt group
sudo usermod --append --groups kvm,libvirt "${USER}"
# Fix-up permission to avoid "Could not access KVM kernel module: Permission denied" error
sudo chown root:kvm /dev/kvm
sudo chmod 660 /dev/kvm
# Stat required services
sudo libvirtd &
sudo virtlogd &
# Launch virt-manager
virt-manager &
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.