简体   繁体   English

由于版本问题,安装 virt-manager 时出错

[英]Error while installing virt-manager due to versioning issues

I was on Linux Mint 19.3 and upgraded to 20 a day ago, and I am now testing all my software to make sure they still work.我在 Linux Mint 19.3 上并在一天前升级到 20,我现在正在测试我的所有软件以确保它们仍然可以工作。 Virt-manager doesn't work right now (but it does in 19.3), and I am very perplexed as to why. Virt-manager 现在不起作用(但在 19.3 中起作用),我很困惑为什么。 Virsh seems to work fine: 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 seems to work fine too: KVM 似乎也可以正常工作:

kelvin@mint-1:/usr/share$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Libvirtd seems to be working too: 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

Then I decided to run virt-manager:然后我决定运行 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'

So the problem is clearly missing libxml2 right?所以问题显然是缺少libxml2对吗? I look everywhere, and what I found out is that libxml2 is a C library/binary, installed using apt install libxml2 , and lxml is a python binding to libxml2 , installed using pip3 install lxml .我到处寻找,我发现libxml2是一个 C 库/二进制文件,使用apt install libxml2 ,而lxml是一个 python 绑定到libxml2 ,使用pip3 install lxml All well and good.一切都很好。 But then again, it still outputs that error.但话又说回来,它仍然输出该错误。 So I went into the file /usr/share/virt-manager/virtinst/xmlapi.py and change import libxml2 to import lxml as libxml2 .所以我进入文件/usr/share/virt-manager/virtinst/xmlapi.py并将import libxml2更改为import lxml as libxml2

This approach works great, and virt-manager starts up as usual.这种方法效果很好,virt-manager 照常启动。 But then, I can't connect to QEMU/KVM for some reason, so I decided to delete the connection entirely, and recreate the connection again, still using the default URL qemu:///system .但是,由于某种原因,我无法连接到 QEMU/KVM,所以我决定完全删除连接,然后重新创建连接,仍然使用默认的 URL qemu:///system But then, it can't connect, and it dumps this log:但是,它无法连接,并转储此日志:

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'

This is the point where it throws an error:这是它引发错误的地方:

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())

I tried to comment out that section, but it still throws an error at another location.我试图注释掉该部分,但它仍然在另一个位置引发错误。 The only definition I can see is this:我能看到的唯一定义是:

def invalidate_caps(self):
    return self._backend.invalidate_caps()
caps = property(lambda self: getattr(self, "_backend").caps)

Right now, I am so deep into this that I feel like I am missing something if I am actually changing the source code.现在,我对此非常深入,以至于如果我真的在更改源代码,我会觉得我错过了一些东西。 So where was I wrong?那我哪里错了?

I figured out the solution!我想出了解决方案! Following the instructions here (in Chinese, but I'm not Chinese, so chrome automatically translates it for me), I only need to execute pip3 install libxml2-python3 , and don't have to mess around with changing import libxml2 to import lxml .按照这里的说明(中文,但我不是中文,所以chrome会自动为我翻译),我只需要执行pip3 install libxml2-python3 ,不必乱改import libxml2import lxml .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM