Failed to acquire pid file : /var/local/run/libvirt/qemu/driver.pid

Hello.

I'm running Debian bookworm on my ARM Chromebook,model "xe303c12" and I've recompiled the kernel to enable KVM,so now my system sounds like this :

$ lsb_release -a
No LSB modules are available. 
Distributor ID: Debian 
Description:    Debian GNU/Linux 12 (bookworm) 
Release:        12 
Codename:       bookworm

$ uname -a 
Linux chromarietto 5.4.244-stb-cbe 
#8 SMP PREEMPT Sat Aug 19 22:19:32 UTC 2023 armv7l GNU/Linux

$ uname -r 
5.4.244-stb-cbe

$ kvm-ok 
INFO: /dev/kvm exists 
KVM acceleration can be used

$ qemu-system-arm --version
QEMU emulator version 5.1.0 (v5.1.0-dirty) 
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

$ python3 --version 
Python 3.11.2

I have installed libvirt 9.7.0,qemu 5.1 and virt-manager from source code with the final goal to be able to connect qemu,kvm and libvirt together to virtualize FreeBSD 13.2 for arm 32 bit. If you ask me why I've recompiled everything from source code,my answer will be complicated,but in short terms,for some unknown reason, it reports an error like this :

"Warning : Failed to set up UEFI / 
The Libvirt version does not support UEFI /
Install options are limited"

So,I went for the most complicated route : compiling everything from scratch.

Below I pasted the whole procedure that I've followed,so you can understand well what's wrong.

$ apt build-dep libvirt

$ git clone https://github.com/libvirt/libvirt.git 
Cloning into 'libvirt'...

$ cd libvirt 
$ meson setup build 
$ ninja -C build 
$ ninja -C build install

$ which virsh
/usr/local/bin/virsh

$ which libvirtd
/usr/local/sbin/libvirtd

$ apt install libgtk-3-dev libpulse-dev libgbm-dev libspice-protocol-dev \
libspice-server-dev libusb-1.0-0-dev libepoxy-dev libfdt-dev

$ git clone -b v5.1.0 http://git.qemu.org/qemu.git

$ cd qemu-v5.1.0

$ git submodule add -f https://git.kernel.org/pub/scm/utils/dtc/dtc.git dtc

$ ./configure --disable-werror --target-list=arm-softmmu \
--enable-opengl --enable-gtk --enable-kvm --enable-guest-agent \
--enable-spice --audio-drv-list="oss pa" --enable-libusb \
--enable-trace-backend=simple --enable-debug

$ make

$ make install

$ git clone https://github.com/virt-manager/virt-manager.git

$ apt install gobject-introspection libosinfo-1.0-0 libosinfo-1.0-dev \
gir1.2-libosinfo-1.0 libvirt-glib-1.0-dev

$ cd virt-manager 
$ ./setup.py configure --prefix=/usr/local 
$ sudo ./setup.py install

$ sudo usermod -a -G libvirt root 
$ sudo usermod -a -G libvirtd root 
$ sudo usermod -a -G libvirt-qemu libvirt-qemu 
$ sudo usermod -a -G libvirt marietto
$ sudo adduser libvirt-qemu 
$ sudo groupadd --system libvirt 
$ sudo groupadd --system libvirt-qemu 
$ sudo newgrp libvirt-qemu 
$ newgrp libvirt

$ /usr/local/sbin# libvirtd & 
[1] 2875

$ /usr/local/sbin# virtqemud & 

info : libvirt version: 9.7.0 info : 
hostname: chromarietto error : virPidFileAcquirePathFull:409 
Failed to acquire pid file : /var/local/run/libvirt/qemu/driver.pid 
Resource temporarily unavailable error : virStateInitialize:672 : 
Initialization of QEMU state driver failed 
Failed to acquire pid file : /var/local/run/libvirt/qemu/driver.pid 
Resource temporarily unavailable error : daemonRunStateInit:617 : 
Driver state initialization failed

$ /usr/local/sbin# ps ax | grep libvirt 
2875 pts/0    Sl     0:00 libvirtd

$ /usr/local/sbin# ps ax | grep virtqemu 
nothing


If I do the opposite way :


$ /usr/local/sbin# virtqemud &

$ /usr/local/sbin# ps ax | grep virtqemu 
3041 pts/0    Sl     0:00 virtqemud

$ /usr/local/sbin# libvirtd & 

info : libvirt version: 9.7.0 info : 
hostname: chromarietto 
error : virPidFileAcquirePathFull:409 
Failed to acquire pid file : /var/local/run/libvirt/qemu/driver.pid 
Resource temporarily unavailable 
virStateInitialize:672 : Initialization of QEMU state driver failed 
Failed to acquire pid file : /var/local/run/libvirt/qemu/driver.pid 
Resource temporarily unavailable daemon
RunStateInit:617 : Driver state initialization failed

$ /usr/local/sbin# ps ax | grep virtqemu 
3041 pts/0    Sl     0:00 virtqemud

$ /usr/local/sbin# ps ax | grep libvirt 
nothing

In short terms : when I launch libvirt and then virtqemu,the first one does not close itself,but the second one does it ; when I launch virtqemud and then libvirt,the first one does not close itself,but the second one does it ; so,these two processes are not compatible with each other,but they should run both,otherwise virt-manager will not work at all and I will not be able to run any virtual machine.

For some reason it does not pick the existing /run/ or the deprecated /var/run/
Perhaps some magic derives the "local" from the --prefix=/usr/local.
Maybe there is an option to set the pid dir?

After a complicated debug,we have fixed this problem here :

anyway,another problem emerged.

We assume that you are aware that many issues with libvirt co-existing with virtqemu are down to how the daemons are configured. It's critical. You can either configure modular or monolithic daemons but not both.

1 Like

Anyway,to make the story short,I've been able,with the help of a nice guy,to compile and run successfully qemu,libvirt and virt-manager. You can give a look at the full troubleshooting,here :

the end is not good :

[Mon, 28 Aug 2023 18:57:46 virt-manager 2664] DEBUG (createvm:494) UEFI found, setting it as default.

[Mon, 28 Aug 2023 18:57:46 virt-manager 2664] DEBUG (createvm:728) Guest type set to os_type=hvm, arch=armv7l, dom_type=kvm

[Mon, 28 Aug 2023 18:57:46 virt-manager 2664] DEBUG (guest:546) Prefer EFI => True

[Mon, 28 Aug 2023 18:57:47 virt-manager 2664] DEBUG (domcapabilities:250) Error fetching domcapabilities XML

Traceback (most recent call last):

File "/usr/local/share/virt-manager/virtinst/domcapabilities.py", line 245, in build_from_params

xml = conn.getDomainCapabilities(emulator, arch,

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in getDomainCapabilities

raise libvirtError('virConnectGetDomainCapabilities() failed')

libvirt.libvirtError: KVM is not supported on this platform: Function not implemented

[Mon, 28 Aug 2023 18:57:48 virt-manager 2664] DEBUG (domcapabilities:250) Error fetching domcapabilities XML

Traceback (most recent call last):

File "/usr/local/share/virt-manager/virtinst/domcapabilities.py", line 245, in build_from_params

xml = conn.getDomainCapabilities(emulator, arch,

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in getDomainCapabilities

raise libvirtError('virConnectGetDomainCapabilities() failed')

libvirt.libvirtError: KVM is not supported on this platform: Function not implemented

[Mon, 28 Aug 2023 18:57:48 virt-manager 2664] DEBUG (createvm:497) Error checking for UEFI default

Traceback (most recent call last):

File "/usr/local/share/virt-manager/virtManager/createvm.py", line 491, in _set_caps_state

guest.enable_uefi()

File "/usr/local/share/virt-manager/virtinst/guest.py", line 589, in enable_uefi

path = self._lookup_default_uefi_path()

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/share/virt-manager/virtinst/guest.py", line 848, in _lookup_default_uefi_path

raise RuntimeError(_("Libvirt version does not support UEFI."))

RuntimeError: Libvirt version does not support UEFI.

[Mon, 28 Aug 2023 18:57:48 virt-manager 2664] DEBUG (storage:136) Found default pool name=default target=/var/lib/libvirt/images

[Mon, 28 Aug 2023 18:57:48 virt-manager 2664] DEBUG (storage:136) Found default pool name=default target=/var/lib/libvirt/images

[Mon, 28 Aug 2023 18:57:48 virt-manager 2664] DEBUG (engine:316) window counter incremented to 2

[Mon, 28 Aug 2023 18:57:49 virt-manager 2664] DEBUG (connection:691) storage pool refresh event: pool=default

[Mon, 28 Aug 2023 18:57:49 virt-manager 2664] DEBUG (connection:691) storage pool refresh event: pool=default

I don't know the reason for the error,nor the resolution. Any help is appreciated.

I've never tried to configure such a thing on a Chromebook, however, my guess is that it is lying. I would be looking for a configuration error or access rights problem.

What access rights do you have on /dev/kvm??

Are you running everything as root, or some lesser user?

Which users are members of the kvm group?

root@chromarietto:/home/marietto/Desktop# virt-host-validate

QEMU: Checking if device /dev/kvm exists : PASS
QEMU: Checking if device /dev/kvm is accessible : PASS
QEMU: Checking if device /dev/vhost-net exists : PASS
QEMU: Checking if device /dev/net/tun exists : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuset' controller support : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'devices' controller support : PASS
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for device assignment IOMMU support : WARN (No ACPI IORT table found, IOMMU not supported by this hardware platform)
QEMU: Checking for secure guest support : WARN (Unknown if this platform has Secure Guest support)
LXC: Checking for Linux >= 2.6.26 : PASS
LXC: Checking for namespace ipc : PASS
LXC: Checking for namespace mnt : PASS
LXC: Checking for namespace pid : PASS
LXC: Checking for namespace uts : PASS
LXC: Checking for namespace net : PASS
LXC: Checking for namespace user : PASS
LXC: Checking for cgroup 'cpu' controller support : PASS
LXC: Checking for cgroup 'cpuacct' controller support : PASS
LXC: Checking for cgroup 'cpuset' controller support : PASS
LXC: Checking for cgroup 'memory' controller support : PASS
LXC: Checking for cgroup 'devices' controller support : PASS

LXC: Checking for cgroup 'freezer' controller support : FAIL (Enable 'freezer' in kernel Kconfig file or mount/enable cgroup controller in your system)

LXC: Checking for cgroup 'blkio' controller support : PASS
LXC: Checking if device /sys/fs/fuse/connections exists : PASS

I login to the chromebook via ssh with : ssh -Y root@192.168.1.6 and I do everything as root.

you have understood on the fly what was wrong : I hadn't added any user to the kvm group. now I did it and the error changed :


[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (createvm:494) UEFI found, setting it as default.
[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (createvm:728) Guest type set to os_type=hvm, arch=armv7l, dom_type=kvm
[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (guest:546) Prefer EFI => True
2023-08-29 10:10:12.972+0000: 1765: error : virHostCPUGetKVMMaxVCPUs:1228 : KVM is not supported on this platform: Function not implemented
[Tue, 29 Aug 2023 10:10:12 virt-manager 2141] DEBUG (domcapabilities:250) Error fetching domcapabilities XML
Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virtinst/domcapabilities.py", line 245, in build_from_params
    xml = conn.getDomainCapabilities(emulator, arch,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in getDomainCapabilities
    raise libvirtError('virConnectGetDomainCapabilities() failed')
libvirt.libvirtError: KVM is not supported on this platform: Function not implemented
2023-08-29 10:10:14.157+0000: 1762: error : virHostCPUGetKVMMaxVCPUs:1228 : KVM is not supported on this platform: Function not implemented
[Tue, 29 Aug 2023 10:10:14 virt-manager 2141] DEBUG (domcapabilities:250) Error fetching domcapabilities XML
Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virtinst/domcapabilities.py", line 245, in build_from_params
    xml = conn.getDomainCapabilities(emulator, arch,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in getDomainCapabilities
    raise libvirtError('virConnectGetDomainCapabilities() failed')
libvirt.libvirtError: KVM is not supported on this platform: Function not implemented
[Tue, 29 Aug 2023 10:10:14 virt-manager 2141] DEBUG (createvm:497) Error checking for UEFI default
Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virtManager/createvm.py", line 491, in _set_caps_state
    guest.enable_uefi()
  File "/usr/local/share/virt-manager/virtinst/guest.py", line 589, in enable_uefi
    path = self._lookup_default_uefi_path()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/share/virt-manager/virtinst/guest.py", line 848, in _lookup_default_uefi_path
    raise RuntimeError(_("Libvirt version does not support UEFI."))
RuntimeError: Libvirt version does not support UEFI

this is the error that has been added now :

root@chromarietto:~# virsh domcapabilities --machine virt --emulatorbin /usr/local/bin/qemu-system-arm

2023-08-29 10:17:59.110+0000: 1763: error : virHostCPUGetKVMMaxVCPUs:1228 : KVM is not supported on this platform: Function not implemented
error: failed to get emulator capabilities
error: KVM is not supported on this platform: Function not implemented

ARM Chromebook does not support Crostini.