我刚刚(愚蠢地)完成了从 14.04.4 到 16.04 的升级。显然,由于引入了 systemd,导致 libvirt 出现错误……或者我破坏了 aptitude。有解决方法或修复方法吗?我应该回到 14.04 吗?
root@KVM0:~# apt-get install libvirt-bin
Reading package
lists... Done
Building dependency tree
Reading state information... Done
libvirt-bin is already the newest version (1.3.1-1ubuntu10).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up libvirt-bin (1.3.1-1ubuntu10) ...
Job for libvirt-bin.service failed because the control process exited with error code. See "systemctl status libvirt-bin.service" and "journalctl -xe" for details.
invoke-rc.d: initscript libvirt-bin, action "start" failed.
dpkg: error processing package libvirt-bin (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
libvirt-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
这似乎是由 apparmor 引起的,因为您会在系统日志中发现类似这样的内容:
内核:[2386.130467] 审核:类型 = 1400 审核(1461767119.644:89):apparmor =“DENIED”操作 =“创建”配置文件 =“/usr/sbin/libvirtd”pid = 21368 comm =“libvirtd”family =“netlink”sock_type =“raw”协议 = 0 requested_mask =“创建”denied_mask =“创建”
在该错误修复之前,一个不安全的解决方法是暂时禁用安装的 apparmor:
sudo systemctl stop apparmor.service
sudo apt-get -f install
sudo systemctl start apparmor.service
答案2
请不要取消注释此内容/etc/libvirt/libvirtd.conf
:
# You need to uncomment this line
log_outputs="3:syslog:libvirtd"
保留默认设置,例如:
# You need to uncomment this line
#log_outputs="3:syslog:libvirtd"
在官方 libvirt wiki 中提到了这一点:http://wiki.libvirt.org/page/The_daemon_cannot_be_started,但这根本没有帮助。
最好的选择是首先运行:
sudo systemctl stop apparmor.service
sudo apt-get -f install
sudo systemctl start apparmor.service
然后你可以尝试:
systemctl status libvirt-bin.service
其输出应如下所示:
libvirt-bin.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirt-bin.service; enabled; vendor prese
Active: active (running) since Fr 2016-08-19 14:02:04 EST; 43s ago
Docs: man:libvirtd(8)
http://libvirt.org
Main PID: 8620 (libvirtd)
CGroup: /system.slice/libvirt-bin.service
├─8620 /usr/sbin/libvirtd
├─9013 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
└─9014 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.
答案3
我在使用 apt dist-upgrade 时也遇到了类似的问题。我通过停止 libvirt-bin 服务并终止所有正在运行的 libvirt 进程来修复此问题。