Here’s an explanation of how to build qemu-kvm , libvirtd and virt-manager from source including trial and error.
# uname -ri
3.0.0-15-generic x86_64
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"
|
[ uninstall kvm , libvirt-bin , virt-manager via apt-get if you have installed them ]
# apt-get remove kvm libvirt-bin virt-manger –y
# apt-get autoremove
|
back up the current libvirtd configuration.
# tar czvf libvirt.tgz /etc/libvirt/
tar: メンバ名から先頭の `/' を取り除きます
/etc/libvirt/
/etc/libvirt/storage/
/etc/libvirt/storage/default.xml
/etc/libvirt/storage/disk1.xml
/etc/libvirt/storage/autostart/
/etc/libvirt/storage/autostart/default.xml
/etc/libvirt/storage/autostart/disk1.xml
/etc/libvirt/qemu/
/etc/libvirt/qemu/centos6-32-vm1.xml
/etc/libvirt/qemu/centos6-64-vm1.xml
/etc/libvirt/qemu/networks/
/etc/libvirt/qemu/networks/autostart/
/etc/libvirt/qemu/networks/autostart/default.xml
|
rm /usr/bin/kvm which is a symbolic file to /usr/bin/qemu-system-x86_64.
# rm -rf /usr/bin/kvm
|
[ build qemu-kvm from source ]
download qemu-kvm-1.0.tar.gz from http://sourceforge.net/projects/kvm/files/qemu-kvm/1.0/
and build it.
# tar xzvf qemu-kvm-1.0.tar.gz
# ./configure
# make
# make install
# ls /usr/local/bin/qemu-*
/usr/local/bin/qemu-ga /usr/local/bin/qemu-nbd
/usr/local/bin/qemu-img /usr/local/bin/qemu-system-x86_64
/usr/local/bin/qemu-io
# /usr/local/bin/qemu-system-x86_64 --version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard
|
[ build libvirt ]
download libvirt-0.9.9 tar.gz from http://libvirt.org/sources/ and build it.
# tar xzvf libvirt-0.9.9.tar.gz
# cd libvirt-0.9.9/
|
nn , error
# ./configure
checking for LIBXML... no
checking libxml2 xml2-config >= 2.6.0 ... configure: error: Could not find libxml2 anywhere (see config.log for details).
|
I have already installed libxml2 via apt-get
# dpkg -l libxml2 | tail -1
ii libxml2 2.7.8.dfsg-4ubuntu0.1 GNOME XML library
# dpkg -L libxml2 | grep "/lib/"
/usr/lib/libxml2.so.2.7.8
/usr/lib/libxml2.so.2
|
error
# ./configure --with-libxml=/usr/lib
checking pkg-config is at least version 0.9.0... yes
checking libxml2 /usr/lib/bin/xml2-config >= 2.6.0 ... configure: error: Could not find libxml2 anywhere (see config.log for details).
|
install libxml2-dev
# apt-get install libxml2-dev -y
|
# dpkg -l libxml2*
ii libxml2 2.7.8.dfsg-4ub GNOME XML library
ii libxml2-dev 2.7.8.dfsg-4ub Development files for the GNOME XML library
ii libxml2-utils 2.7.8.dfsg-4ub XML utilities
|
try again. another error.
# ./configure
configure: error: You must install the GnuTLS library in order to compile and run libvirt
|
install gnutls via apt-get
# apt-get install gnutls-bin gnutls-dev
|
# ./configure
configure: error: You must install device-mapper-devel/libdevmapper >= 1.0.0 to compile libvirt
|
# apt-get install libdevmapper-dev libdevmapper
|
# ./configure
configure: error: You must install python-devel to build Python bindings
|
# apt-cache search python-dev
|
# ./configure
checking for LIBNL... no
configure: error: libnl-devel >= 1.1 is required for macvtap support
|
# apt-get install libnl1 libnl-dev
|
# ./configure
configure: Readline: no
configure: Python: yes
configure: DTrace: no
configure: XML Catalog: /etc/xml/catalog
configure: Init script: check
configure:
configure: Privileges
configure:
configure: QEMU: root:root
configure:#
|
# make
# make install
|
# ls /usr/local/bin/vir*
/usr/local/bin/virsh /usr/local/bin/virt-install
/usr/local/bin/virt-clone /usr/local/bin/virt-pki-validate
/usr/local/bin/virt-convert /usr/local/bin/virt-xml-validate
/usr/local/bin/virt-image
# /usr/local/sbin/libvirtd --version
/usr/local/sbin/libvirtd (libvirt) 0.9.9
|
[ build virt-manager ]
download virtinst 0.600.1 and virt-manager 0.90.1 from http://virt-manager.org/download.html
At first , build virtinst
# tar xzvf virtinst-0.600.1.tar.gz # cd virtinst-0.600.1 # python setup.py install |
build virt-manager
# tar xzvf virt-manager-0.9.1.tar.gz # cd virt-manager-0.9.1/ # ./configure configure: Required virtinst: 0.600.1 configure: Default qemu user: root configure: Install TUI: yes configure: Enable unsupported RHEL options: yes configure: Preferred distros: none configure: Libvirt packages: none configure: KVM packages: none configure: Default graphics: vnc # make # ls /usr/local/bin/virt-ma* /usr/local/bin/virt-manager /usr/local/bin/virt-manager-tui |
Okay , get everything done , I think..
[ start libvirtd ]
start libvirtd ( -d : run libvirtd as daemon. )
# /usr/local/sbin/libvirtd –d |
[ connect to libvirt via virsh ]
# LANG=C /usr/local/bin/virsh virsh # version Compiled against library: libvir 0.9.9 Using library: libvir 0.9.9 Using API: QEMU 0.9.9 Running hypervisor: QEMU 1.0.0 |
[ connect to libvirt via virt-manager ]
$ /usr/local/bin/virt-manager import urlgrabber.progress as progress ImportError: No module named urlgrabber.progress |
install python-urlgrabber
# apt-get install python-urlgrabber -y |
$ /usr/local/bin/virt-manager import gtkvnc ImportError: No module named gtkvnc |
# apt-get install –y libgtk-vnc-1.0-0 python-gtk-vnc |
GUI has appeared.. however I can’t connect to livbirtd.
Unable to connect to libvirt: File "/usr/local/lib/python2.7/dist-packages/libvirt.py", line 102, in openAuth if ret is None:raise libvirtError('virConnectOpenAuth() failed') |
I can connect to libvirtd via virsh , so I think libvirtd is running.
# LANG=C /usr/local/bin/virsh -c qemu:///system Welcome to virsh, the virtualization interactive terminal. virsh # version Compiled against library: libvir 0.9.9 Using library: libvir 0.9.9 Using API: QEMU 0.9.9 Running hypervisor: QEMU 1.0.0 virsh # quit |
Let’s check the libvirt.log .. Auth fail from a user which UID is 1000.
UID 1000 is an account which I always use when logging on Mint.
# tail -f /usr/local/var/log/libvirt/libvirtd.log error : remoteDispatchAuthPolkit:2521 : PolicyKit がアクション org.libvirt.unix.manage を PID 18318, UID 1000 から拒否しま した: 終了ステータス 127 error : remoteDispatchAuthPolkit:2540 : 認 証に失敗しました: 認証に失敗しました # egrep 1000 /etc/group hattori:x:1000: |
confirm whether or not UID 1000 can connect to libvirt.
nnn , authentication failed when connecting to libvirt with UID 1000.
# /usr/local/bin/virsh -c qemu+ssh://hattori@127.0.0.1/system hattori@127.0.0.1's password: error: 認証に失敗しました: 認証に失敗しました error: failed to connect to the hypervisor |
how about root user ? .. can connect to libvirt with root user.
It might be permission problems..
# /usr/local/bin/virsh -c qemu+ssh://root@127.0.0.1/system root@127.0.0.1's password: Welcome to virsh, the virtualization interactive terminal. virsh # quit |
run libvird with debug mode and start virt-manager to locate the problem.
# LIBVIRT_DEBUG=1 /usr/local/sbin/libvirtd > libvirt.logs 2>&1 # /usr/local/bin/virt-manager |
debug logs.
Error checking for authorization org.libvirt.unix.manage: GDBus.Error:org.freede sktop.PolicyKit1.Error.Failed: Action org.libvirt.unix.manage is not registered 20844: error : remoteDispatchAuthPolkit:2521 : PolicyKit がアクション org.libvirt.unix.manage を PID 20894, UID 1000 から拒否しま した: 終了ステータス 127 20844: debug : remoteDispatchAuthPolkit:2554 : RPC_SERVER_CLIENT_AUTH_DENY: client=0x7fa510000ae0 auth=2 identity=pid:20894,uid:1000 20844: error : remoteDispatchAuthPolkit:2540 : 認 証に失敗しました: 認証に失敗しました |
PolicyKit ?
Let’s google it.
It seems that Policy kit is an ACL for user authentication
http://libvirt.org/auth.html
Allow UID 1000 named hattori to connect to libvirtd
# cat /etc/polkit-1/localauthority/50-local.d/50-org.libvirt.access.pkla [libvirt Management Access] Identity=unix-user:hattori Action=org.libvirt.unix.manage ResultAny=yes ResultInactive=yes ResultActive=yes |
try again ,,, same error
Error checking for authorization org.libvirt.unix.manage: GDBus.Error:org.freede sktop.PolicyKit1.Error.Failed: Action org.libvirt.unix.manage is not registered error : remoteDispatchAuthPolkit:2521 : PolicyKit がアクション org.libvirt.unix.manage を PID 20894, UID 1000 から拒否しま した: 終了ステータス 127 20844: debug : remoteDispatchAuthPolkit:2554 : RPC_SERVER_CLIENT_AUTH_DENY: client=0x7fa510000ae0 auth=2 identity=pid:20894,uid:1000 20844: error : remoteDispatchAuthPolkit:2540 : 認 証に失敗しました: 認証に失敗しました |
oh ,, I also need to edit libvirtd.conf.
# groupadd libvirt # usermod -G libvirt -a hattori |
# egrep unix_sock /usr/local/etc/libvirt/libvirtd.conf | grep -v ^# unix_sock_group = "libvirt" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0770" |
nn still error
Error checking for authorization org.libvirt.unix.manage: GDBus.Error:org.freede sktop.PolicyKit1.Error.Failed: Action org.libvirt.unix.manage is not registered error : remoteDispatchAuthPolkit:2521 : PolicyKit がアクション org.libvirt.unix.manage を PID 23628, UID 1000 から拒否しま した: 終了ステータス 127 |
nnn , okey ,, disable Policykit auth.
# egrep '(unix_sock|none)' /usr/local/etc/libvirt/libvirtd.conf | grep -v ^# unix_sock_group = "libvirt" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0770" auth_unix_ro = "none" auth_unix_rw = "none" |
try again
# LIBVIRT_DEBUG=1 /usr/local/sbin/libvirtd -d > libvirt.logs 2>&1 |
I can connect to libvirt with UID 1000.
# LANG=C /usr/local/bin/virsh -c qemu+ssh://hattori@127.0.0.1/system hattori@127.0.0.1's password: Welcome to virsh, the virtualization interactive terminal. virsh # version Compiled against library: libvir 0.9.9 Using library: libvir 0.9.9 Using API: QEMU 0.9.9 Running hypervisor: QEMU 1.0.0 virsh # quit |
try to connect libvirtd via virt-manager. another error
$ /usr/local/bin/virt-manager –debug if ret is None:raise libvirtError('virConnectOpenAuth() failed') libvirtError: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': Permission denied |
# egrep '(unix_sock|none)' /usr/local/etc/libvirt/libvirtd.conf | grep -v ^# unix_sock_group = "libvirt" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0777" unix_sock_dir = "/usr/local/var/run/libvirt" auth_unix_ro = "none" auth_unix_rw = "none" |
can connect to libvirtd both virsh and virt-manager with UID 1000.
[ fly a VM on KVM 1.0 ]
make a symbolic link.
virsh or virt-manager seems to check /usr/bin/kvm or /usr/local/bin/kvm when starting a VM.
# ln -s /usr/local/bin/qemu-system-x86_64 /usr/bin/kvm |
install a VM via virsh or virt-manager.
a VM , CentOS6 32bit , is running on KVM 1.0.
virsh # list –all Id Name State ---------------------------------- 1 centos6-32-vm1 running virsh # qemu-monitor-command centos6-32-vm1 'info version 1.0.0 (qemu-kvm-1.0) |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.