WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: virt-manager fails to import libxml2  (Read 353 times)

Offline Leee

  • Full Member
  • ***
  • Posts: 135
virt-manager fails to import libxml2
« on: January 22, 2025, 04:19:57 PM »
This is not an urgent thing, since I just downloaded virt-manager on a whim to try it out, but...

I downloaded and installed virt-manager.tcz on Core 15.0 / x86_64 and when I try to run it, I get the following error output:
Code: [Select]
tc@dolly:~$ virt-manager
Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virt-manager", line 19, in <module>
    from virtinst import BuildConfig
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/__init__.py", line 49, in <module>
    from virtinst.domain import *  # pylint: disable=wildcard-import
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
    from .blkiotune import DomainBlkiotune
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
    from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
    from .xmlapi import XMLAPI
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
    import libxml2
ModuleNotFoundError: No module named 'libxml2'

Both libxml2.tcz and libxml2-python.tcz are loaded.

Looking at /tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/xmlapi.py line #7, it looks like libxml2-python should do the job, but apparently not (though I'm -still- not exactly a python guy).
« Last Edit: January 22, 2025, 04:45:59 PM by Leee »
core 15.0 x86_64

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11794
Re: virt-manager fails to import libxml2
« Reply #1 on: January 22, 2025, 04:52:14 PM »
Hi Leee
You didn't mention it, so I have to ask, did you:
Code: [Select]
$ sudo modprobe kvm-intel
$ sudo /usr/local/etc/init.d/dbus start
$ sudo libvirtd -d
$ sudo virtlogd -d
  ..then start virt-manager
as specified by the .info file:
http://tinycorelinux.net/15.x/x86_64/tcz/virt-manager.tcz.info

Offline Leee

  • Full Member
  • ***
  • Posts: 135
Re: virt-manager fails to import libxml2
« Reply #2 on: January 22, 2025, 05:07:55 PM »
Ummm... no.    :-[

But when I do that, modprobe fails with:

Code: [Select]
tc@dolly:~$ sudo modprobe kvm-intel
modprobe: can't load module kvm-intel (kernel.tclocal/arch/x86/kvm/kvm-intel.ko.gz): Operation not supported
core 15.0 x86_64

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11794
Re: virt-manager fails to import libxml2
« Reply #3 on: January 22, 2025, 05:25:49 PM »
Hi Leee
I think that means your CPU doe not support virtualization.
Or it might mean virtualization is disabled in your BIOS.

Offline Leee

  • Full Member
  • ***
  • Posts: 135
Re: virt-manager fails to import libxml2
« Reply #4 on: January 22, 2025, 05:55:55 PM »
Thanks Rich

The CPU is an "Intel(R) Core(TM) i5-6200U" that supposedly has "Enhanced Virtualization" so I think it's ok.  I'll reboot later today and snoop around the BIOS settings for anything having to do with virtualization.  That wil, no doubt tell the story regarding kvm-intel.ko.gz but...

I'm wondering if any of that would have to do with loading the libxml2 stuff - seems unlikely to be related, though I suppose one never knows.
core 15.0 x86_64

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11794
Re: virt-manager fails to import libxml2
« Reply #5 on: January 22, 2025, 09:17:08 PM »
Hi Leee
Just a little story in case your machine has a similar issue.

Last year someone gave me a Sony VAIO VGN-FZ240E laptop.
It has an "Intel Core 2 Duo T7250" CPU which is capable of
virtualization, yet I could not load kvm-intel.

After some online searching I found the manufacturer (VAIO) disabled
virtualization in the BIOS and provided no way to enable it.

Some more searching turned up a program that could read the CMOS
settings and save the contents in a text file.
I also found a list of what many of those locations do.
I changed the virtualization location to enable it.
I then used the program to write the text file back to CMOS memory.

I was then able to load kvm-intel.

Offline Leee

  • Full Member
  • ***
  • Posts: 135
Re: virt-manager fails to import libxml2
« Reply #6 on: January 23, 2025, 04:05:04 AM »
Hi Rich,
I did pause during reboot to check the BIOS settings and virtualization was disabled there.  I enabled it and that allowed sudo modprobe kvm-intel to succeed:
Code: [Select]
tc@dolly:~$ sudo modprobe kvm-intel
tc@dolly:~$ sudo /usr/local/etc/init.d/dbus start
starting dbus daemon...
tc@dolly:~$ sudo libvirtd -d
tc@dolly:~$ sudo virtlogd -d

However, the issue with libxml2 remains:
Code: [Select]
tc@dolly:~$ virt-manager
Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virt-manager", line 19, in <module>
    from virtinst import BuildConfig
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/__init__.py", line 49, in <module>
    from virtinst.domain import *  # pylint: disable=wildcard-import
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
    from .blkiotune import DomainBlkiotune
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
    from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
    from .xmlapi import XMLAPI
  File "/tmp/tcloop/virt-manager/usr/local/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
    import libxml2
ModuleNotFoundError: No module named 'libxml2'
core 15.0 x86_64

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14914
Re: virt-manager fails to import libxml2
« Reply #7 on: January 23, 2025, 09:48:20 AM »
The missing module is in /usr/local/lib/python3.9/site-packages/libxml2.py

I'd guess that virt-manager is either looking in /usr/local/lib/python3.6/site-packages for the module or it is missing a symlink python -> python3.9 or python3 -> python3.9?

Offline Leee

  • Full Member
  • ***
  • Posts: 135
Re: virt-manager fails to import libxml2
« Reply #8 on: January 23, 2025, 03:10:07 PM »
The missing module is in /usr/local/lib/python3.9/site-packages/libxml2.py

I'd guess that virt-manager is either looking in /usr/local/lib/python3.6/site-packages for the module or it is missing a symlink python -> python3.9 or python3 -> python3.9?

Neither of those two symlinks did the trick but the following got me some progress:
Code: [Select]
# these two allowed virt-manager to start up w/o errors:
sudo cp /usr/local/lib/python3.9/site-packages/libxml2.py /usr/local/lib/python3.6/site-packages/
sudo cp /usr/local/lib/python3.9/site-packages/libxml2.py /usr/local/lib/python3.6/site-packages/

# these two allowed the "File   /   New Virtual Machine" dialog to start up without too much complaining:
sudo cp /usr/local/share/lshw/pci.ids.gz /usr/local/share/hwdata/pci.ids.gz
sudo cp /usr/local/share/lshw/usb.ids.gz /usr/local/share/hwdata/usb.ids.gz
# although it still says"Error: No active connection to install on." ... but that could just be me not having a clue.

The whole thing feels like I've made hash of it (at the very least, it looks like both python 3.6 and python 3.9 are present) so I'll probably reboot to a clean system, then load virt-manager by itself and see what happens.
core 15.0 x86_64

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 730
Re: virt-manager fails to import libxml2
« Reply #9 on: January 23, 2025, 04:30:48 PM »
You have to tell virtmanager what HV you using, something like this.
Code: [Select]
export LIBVIRT_DEFAULT_URI=qemu:///system

And start the network.
Code: [Select]
sudo virsh net-start default-network

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11794
Re: virt-manager fails to import libxml2
« Reply #10 on: January 23, 2025, 04:52:56 PM »
Hi Leee
... The whole thing feels like I've made hash of it (at the very least, it looks like both python 3.6 and python 3.9 are present) ...
It's not you.
virt-manager.tcz.dep:
Code: [Select]
py3.6gobject.tcz
libvirt-glib-gir.tcz
libosinfo-gir.tcz
libvirt-python3.6.tcz
python3.6-requests.tcz
vte-gir.tcz
libxml2-python.tcz
polkit.tcz
gtksourceview4-gir.tcz
libsoup.tcz
qemu.tcz
gtk-vnc-gir.tcz
spice-gtk-gir.tcz
You can see it's pulling in python 3.6 dependencies as well as libxml2-python.tcz.

libxml2-python.tcz.dep:
Code: [Select]
libxml2.tcz
python3.9.tcz
And here's where the python 3.9 dependency gets pulled in.

Offline Leee

  • Full Member
  • ***
  • Posts: 135
Re: virt-manager fails to import libxml2
« Reply #11 on: January 24, 2025, 02:23:46 AM »
Thanks Rich.
I just tried rebooting with just the basic GUI elements then loaded virt-manager with tce-load -i  and wasn't too surprised to see both versions of python getting pulled int.

core 15.0 x86_64

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14914
Re: virt-manager fails to import libxml2
« Reply #12 on: January 24, 2025, 04:29:34 AM »
I'll add it to the "to do" queue..

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14914
Re: virt-manager fails to import libxml2
« Reply #13 on: January 24, 2025, 11:17:26 AM »
virt-manager recompiled against python3.9

You'll probably need to create pci.ids.gz and usb.ids.gz from /usr/local/share/hwdata/pci.ids and usb.ids

virt-manager now starts, but I haven't tested any more than that.