由于版本控制问题,安装 virt-manager 时出错
Error while installing virt-manager due to versioning issues
我在 Linux Mint 19.3 上,一天前升级到 20,我现在正在测试我所有的软件以确保它们仍然有效。 Virt-manager 现在不工作(但在 19.3 中可以),我很困惑为什么。 Virsh 似乎工作正常:
kelvin@mint-1:/usr/share$ virsh list --all
Id Name State
--------------------------------
- kali shut off
- ubuntu18.04 shut off
- ubuntu20.04 shut off
- ubuntu20.04.2 shut off
- win10 shut off
KVM 似乎也能正常工作:
kelvin@mint-1:/usr/share$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
Libvirtd 似乎也在工作:
kelvin@mint-1:/usr/share$ service libvirtd status
● libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-07-07 11:09:16 EDT; 1h 2min ago
TriggeredBy: ● libvirtd-ro.socket
● libvirtd-admin.socket
● libvirtd.socket
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 16336 (libvirtd)
Tasks: 25 (limit: 32768)
Memory: 48.1M
CGroup: /system.slice/libvirtd.service
├─ 1548 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1549 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1610 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1613 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1716 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi2.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1717 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi2.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1801 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi3.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1803 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi3.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
└─16336 /usr/sbin/libvirtd
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1548]: read /var/lib/libvirt/dnsmasq/wifi1.hostsfile
Jul 07 11:09:16 mint-1 dnsmasq[1610]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1610]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jul 07 11:09:16 mint-1 dnsmasq[1801]: read /etc/hosts - 12 addresses
Jul 07 11:09:16 mint-1 dnsmasq[1801]: read /var/lib/libvirt/dnsmasq/wifi3.addnhosts - 0 addresses
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1801]: read /var/lib/libvirt/dnsmasq/wifi3.hostsfile
Jul 07 11:09:16 mint-1 libvirtd[16336]: libvirt version: 6.0.0, package: 0ubuntu8.1 (Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 20 May 2020 06:59:57 +0200)
Jul 07 11:09:16 mint-1 libvirtd[16336]: hostname: mint-1
Jul 07 11:09:16 mint-1 libvirtd[16336]: ignoring dangling symlink '/home/kelvin/.steampath'
Jul 07 11:10:51 mint-1 libvirtd[16336]: End of file while reading data: Input/output error
然后我决定运行 virt-manager:
kelvin@mint-1:/usr/share$ virt-manager
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager", line 19, in <module>
from virtinst import BuildConfig
File "/usr/share/virt-manager/virtinst/__init__.py", line 49, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
ModuleNotFoundError: No module named 'libxml2'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_share_virt-manager_virt-manager.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager", line 19, in <module>
from virtinst import BuildConfig
File "/usr/share/virt-manager/virtinst/__init__.py", line 49, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
ModuleNotFoundError: No module named 'libxml2'
所以问题显然是缺失的 libxml2
对吧?我到处看,发现 libxml2
是 C library/binary,使用 apt install libxml2
安装,lxml
是 python 绑定到 libxml2
,使用 pip3 install lxml
安装。一切都很好。但话又说回来,它仍然输出那个错误。所以我进入文件 /usr/share/virt-manager/virtinst/xmlapi.py
并将 import libxml2
更改为 import lxml as libxml2
.
这种方法效果很好,而且 virt-manager 照常启动。但是后来,由于某种原因我无法连接到 QEMU/KVM,所以我决定完全删除连接,并重新创建连接,仍然使用默认的 URL qemu:///system
。但是,它无法连接,并转储此日志:
Unable to connect to libvirt qemu:///system.
'virConnect' object has no attribute 'caps'
Libvirt URI is: qemu:///system
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/connection.py", line 1033, in _open_thread
self._populate_initial_state()
File "/usr/share/virt-manager/virtManager/connection.py", line 991, in _populate_initial_state
self.get_uri(), self.caps.get_xml())
File "/usr/share/virt-manager/virtManager/connection.py", line 314, in <lambda>
caps = property(lambda self: getattr(self, "_backend").caps)
File "/usr/share/virt-manager/virtinst/connection.py", line 118, in __getattr__
return getattr(libvirtconn, attr)
AttributeError: 'virConnect' object has no attribute 'caps'
这是它抛出错误的地方:
def _populate_initial_state(self):
log.debug("libvirt version=%s",
self._backend.local_libvirt_version())
log.debug("daemon version=%s",
self._backend.daemon_version())
log.debug("conn version=%s", self._backend.conn_version())
log.debug("%s capabilities:\n%s",
self.get_uri(), self.caps.get_xml())
我试图注释掉该部分,但它仍然在另一个位置引发错误。我能看到的唯一定义是:
def invalidate_caps(self):
return self._backend.invalidate_caps()
caps = property(lambda self: getattr(self, "_backend").caps)
现在,我对此非常深入,以至于如果我真的在更改源代码,我觉得我错过了一些东西。那我哪里错了?
我找到解决办法了!按照说明here(中文的,不过我不是中文,所以chrome自动帮我翻译了),我只需要执行pip3 install libxml2-python3
,不用乱将 import libxml2
更改为 import lxml
.
我在 Linux Mint 19.3 上,一天前升级到 20,我现在正在测试我所有的软件以确保它们仍然有效。 Virt-manager 现在不工作(但在 19.3 中可以),我很困惑为什么。 Virsh 似乎工作正常:
kelvin@mint-1:/usr/share$ virsh list --all
Id Name State
--------------------------------
- kali shut off
- ubuntu18.04 shut off
- ubuntu20.04 shut off
- ubuntu20.04.2 shut off
- win10 shut off
KVM 似乎也能正常工作:
kelvin@mint-1:/usr/share$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
Libvirtd 似乎也在工作:
kelvin@mint-1:/usr/share$ service libvirtd status
● libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-07-07 11:09:16 EDT; 1h 2min ago
TriggeredBy: ● libvirtd-ro.socket
● libvirtd-admin.socket
● libvirtd.socket
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 16336 (libvirtd)
Tasks: 25 (limit: 32768)
Memory: 48.1M
CGroup: /system.slice/libvirtd.service
├─ 1548 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1549 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1610 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1613 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1716 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi2.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1717 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi2.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1801 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi3.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─ 1803 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/wifi3.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
└─16336 /usr/sbin/libvirtd
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1548]: read /var/lib/libvirt/dnsmasq/wifi1.hostsfile
Jul 07 11:09:16 mint-1 dnsmasq[1610]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1610]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jul 07 11:09:16 mint-1 dnsmasq[1801]: read /etc/hosts - 12 addresses
Jul 07 11:09:16 mint-1 dnsmasq[1801]: read /var/lib/libvirt/dnsmasq/wifi3.addnhosts - 0 addresses
Jul 07 11:09:16 mint-1 dnsmasq-dhcp[1801]: read /var/lib/libvirt/dnsmasq/wifi3.hostsfile
Jul 07 11:09:16 mint-1 libvirtd[16336]: libvirt version: 6.0.0, package: 0ubuntu8.1 (Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 20 May 2020 06:59:57 +0200)
Jul 07 11:09:16 mint-1 libvirtd[16336]: hostname: mint-1
Jul 07 11:09:16 mint-1 libvirtd[16336]: ignoring dangling symlink '/home/kelvin/.steampath'
Jul 07 11:10:51 mint-1 libvirtd[16336]: End of file while reading data: Input/output error
然后我决定运行 virt-manager:
kelvin@mint-1:/usr/share$ virt-manager
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager", line 19, in <module>
from virtinst import BuildConfig
File "/usr/share/virt-manager/virtinst/__init__.py", line 49, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
ModuleNotFoundError: No module named 'libxml2'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_share_virt-manager_virt-manager.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager", line 19, in <module>
from virtinst import BuildConfig
File "/usr/share/virt-manager/virtinst/__init__.py", line 49, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
ModuleNotFoundError: No module named 'libxml2'
所以问题显然是缺失的 libxml2
对吧?我到处看,发现 libxml2
是 C library/binary,使用 apt install libxml2
安装,lxml
是 python 绑定到 libxml2
,使用 pip3 install lxml
安装。一切都很好。但话又说回来,它仍然输出那个错误。所以我进入文件 /usr/share/virt-manager/virtinst/xmlapi.py
并将 import libxml2
更改为 import lxml as libxml2
.
这种方法效果很好,而且 virt-manager 照常启动。但是后来,由于某种原因我无法连接到 QEMU/KVM,所以我决定完全删除连接,并重新创建连接,仍然使用默认的 URL qemu:///system
。但是,它无法连接,并转储此日志:
Unable to connect to libvirt qemu:///system.
'virConnect' object has no attribute 'caps'
Libvirt URI is: qemu:///system
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/connection.py", line 1033, in _open_thread
self._populate_initial_state()
File "/usr/share/virt-manager/virtManager/connection.py", line 991, in _populate_initial_state
self.get_uri(), self.caps.get_xml())
File "/usr/share/virt-manager/virtManager/connection.py", line 314, in <lambda>
caps = property(lambda self: getattr(self, "_backend").caps)
File "/usr/share/virt-manager/virtinst/connection.py", line 118, in __getattr__
return getattr(libvirtconn, attr)
AttributeError: 'virConnect' object has no attribute 'caps'
这是它抛出错误的地方:
def _populate_initial_state(self):
log.debug("libvirt version=%s",
self._backend.local_libvirt_version())
log.debug("daemon version=%s",
self._backend.daemon_version())
log.debug("conn version=%s", self._backend.conn_version())
log.debug("%s capabilities:\n%s",
self.get_uri(), self.caps.get_xml())
我试图注释掉该部分,但它仍然在另一个位置引发错误。我能看到的唯一定义是:
def invalidate_caps(self):
return self._backend.invalidate_caps()
caps = property(lambda self: getattr(self, "_backend").caps)
现在,我对此非常深入,以至于如果我真的在更改源代码,我觉得我错过了一些东西。那我哪里错了?
我找到解决办法了!按照说明here(中文的,不过我不是中文,所以chrome自动帮我翻译了),我只需要执行pip3 install libxml2-python3
,不用乱将 import libxml2
更改为 import lxml
.