无法获取pid文件:/var/local/run/libvirt/qemu/driver.pid

无法获取pid文件:/var/local/run/libvirt/qemu/driver.pid

我在我的 ARM Chromebook 上运行 Debian bookworm,型号为“xe303c12”,并且我已经重新编译了内核以启用 KVM,所以现在我的系统听起来像这样:

$ 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

我已经从源代码安装了 libvirt 9.7.0、qemu 5.1 和 virt-manager,最终目标是能够将 qemu、kvm 和 libvirt 连接在一起,为 Arm 32 位虚拟化 FreeBSD 13.2。如果你问我为什么我从源代码重新编译了所有内容,我的答案会很复杂,但简而言之,由于某种未知的原因,它会报告如下错误:

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

所以,我走了最复杂的路线:从头开始编译所有内容。

下面我把我所遵循的整个过程贴出来,这样你就可以很好地理解哪里出了问题。

$ 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

简而言之:当我启动 libvirt 然后启动 virtqemu 时,第一个不会自行关闭,但第二个会自行关闭;当我启动 virtqemud 然后启动 libvirt 时,第一个不会自行关闭,但第二个会自行关闭;所以,这两个进程彼此不兼容,但它们应该同时运行,否则 virt-manager 将根本无法工作,我将无法运行任何虚拟机。

相关内容