lost and found ( for me ? )

Showing posts with label SPICE. Show all posts
Showing posts with label SPICE. Show all posts

install KVM on CentOS 6.3 , use SPICE

[ install KVM on CentOS 6.3 ]


# cat /etc/centos-release
CentOS release 6.3 (Final)

# uname -rn
centos6-1.localdomain 2.6.32-279.2.1.el6.x86_64

# yum groupinstall Virtulization "Virtualization Platform" "Virtualization Client" "Virtualization Tools"

# /usr/libexec/qemu-kvm --version
QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard

# virt-manager --version
0.9.0

# libvirtd --version
libvirtd (libvirt) 0.9.10

start libvirtd
# /etc/init.d/libvirtd start
Starting libvirtd daemon:                                  [  OK  ]


connect to hypervisor with virsh to confirm whether or not libvirtd and virsh work.
# virsh --connect qemu:///system
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
      'quit' to quit

virsh # quit

connect to the hypervisor with root user.
If you try this with regular users , you will see the following error
$ LANG=C virsh --connect qemu:///system
error: authentication failed: Authorization requires authentication but no agent is available.

error: failed to connect to the hypervisor


Same issue will occur with virt-manager.

root user
# virt-manager


connect to the hypervisor


non root user
$ virt-manager


can’t 
connect

error messages are like this:

File "/usr/lib64/python2.6/site-packages/libvirt.py", line 102, in openAuth
   if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirtError: authentication failed: Authorization requires authentication but no agent is available.


add a bridge interface ( not mandatory )
trun on network and turn off NetworkManager.
# chkconfig NetworkManager off
# chkconfig network on

# chkconfig --list | grep -i network
NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off


I’ll associate eth0 with br0.
# pwd
/etc/sysconfig/network-scripts

# cp ifcfg-eth0 ifcfg-br0


edit ifcfg-eth0 like this:
# egrep -v ^# ifcfg-eth0
TYPE=Ethernet
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="Auto eth0"
DEVICE="eth0"
UUID=zzz
ONBOOT=yes
HWADDR=zz
BRIDGE="br0"


edit ifcfg-br0 like this:
# egrep -v ^# ifcfg-br0
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="br0"
DEVICE="br0"
UUID=zz
ONBOOT=yes
HWADDR=zz
IPADDR=x.x.x.x
PREFIX=24
GATEWAY=z.z.z.z
DNS1=y.y.y.y


stop NetworkManager and start network.
# /etc/init.d/NetworkManager stop;/etc/init.d/network restart

Okay , I could create bridge interface which is associated with eth0.
# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.002655e1aefa       no              eth0
virbr0          8000.525400fd7ade       yes             virbr0-nic


[ build a CentOS 6 VM with virt-manager and SPICE ]

install spice packages
# yum install spice-server spice-client spice-protocol –y


change display settings to Spice from VNC





# virsh list --all
Id    Name                           State
----------------------------------------------------
1     centos6-64-1                   running

# virsh dumpxml 1 | grep -i spice
   <channel type='spicevmc'>
     <target type='virtio' name='com.redhat.spice.0'/>
   <graphics type='spice' port='5900' autoport='yes' keymap='ja'/>


connect to the VM with spice client
# spicec -h 127.0.0.1 -p 5900


virsh # list --all
Id    Name                           State
----------------------------------------------------
3     centos6-64-1                   running

virsh # qemu-monitor-command 3 --hmp 'info spice'
Server:
    address: 127.0.0.1:5900
       auth: none
Channel:
    address: 127.0.0.1:50420
    session: 1714636915
    channel: 1:0
Channel:
    address: 127.0.0.1:50421
    session: 1714636915
    channel: 6:0
Channel:
    address: 127.0.0.1:50422
    session: 1714636915
    channel: 5:0
Channel:
    address: 127.0.0.1:50423
    session: 1714636915
    channel: 4:0
Channel:
    address: 127.0.0.1:50424
    session: 1714636915
    channel: 2:0
Channel:
    address: 127.0.0.1:50425
    session: 1714636915
    channel: 3:0


virsh #




Linux Mint 12 : use KVM SPICE


Here’s an explanation of how to use SPICE on Linux Mint.

# uname -ri
3.0.0-14-generic x86_64

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"

at first , install KVM from the default repository
# apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-manager -y

# kvm --version
QEMU emulator version 0.14.1 (qemu-kvm-0.14.1), Copyright (c) 2003-2008 Fabrice Bellard

# libvirtd --version
libvirtd (libvirt) 0.9.2

# LANG=C apt-cache policy qemu-kvm
qemu-kvm:
 Installed: 0.14.1+noroms-0ubuntu6
 Candidate: 0.14.1+noroms-0ubuntu6
 Version table:
*** 0.14.1+noroms-0ubuntu6 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages
       100 /var/lib/dpkg/status

# LANG=C apt-cache policy libvirt-bin
libvirt-bin:
 Installed: 0.9.2-4ubuntu15.1
 Candidate: 0.9.2-4ubuntu15.1
 Version table:
*** 0.9.2-4ubuntu15.1 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric-updates/main amd64 Packages
       100 /var/lib/dpkg/status
    0.9.2-4ubuntu15 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages

add the repository for SPICE support
# add-apt-repository ppa:bderzhavets/qemu-git
You are about to add the following PPA to your system:
Qemu-kvm 0.15.0 and Spice on Ubuntu 11.10
Installed and tested to work on Ubuntu Oneiric Alpha 3 and daily build 08/14/11


upgrade KVM related packages.
# apt-get update ;apt-get upgrade –y
以下のパッケージは保留されます:
 qemu-kvm
以下のパッケージはアップグレードされます:
 libvirt-bin libvirt0 python-libvirt qemu-common


install SPICE packages and upgrade qemu-kvm
# LANG=C apt-get install qemu-kvm qemu qemu-common libspice-client libs
pice-client-dev libspicegtk3-client libspicegtk3-client-dev spice libspice-proto
col-dev spicegtk3-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
qemu-common is already the newest version.
qemu-common set to manually installed.
The following extra packages will be installed:
 libcegui-mk2-1 libcelt051 libdevil1c2 libfreeimage3 libspice-server
 libxerces-c28
The following NEW packages will be installed:
 libcegui-mk2-1 libcelt051 libdevil1c2 libfreeimage3 libspice-client
 libspice-client-dev libspice-protocol-dev libspice-server
 libspicegtk3-client libspicegtk3-client-dev libxerces-c28 qemu spice
 spicegtk3-client
The following packages will be upgraded:
 qemu-kvm

# LANG=C apt-cache policy qemu-kvm
qemu-kvm:
 Installed: 081011-2ubuntu9
 Candidate: 081011-2ubuntu9
 Version table:
*** 081011-2ubuntu9 0
       500 http://ppa.launchpad.net/bderzhavets/qemu-git/ubuntu/ oneiric/main amd64 Packages
       100 /var/lib/dpkg/status
    0.14.1+noroms-0ubuntu6 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages

# LANG=C apt-cache policy libvirt-bin
libvirt-bin:
 Installed: 0.9.2-5ubuntu15
 Candidate: 0.9.2-5ubuntu15
 Version table:
*** 0.9.2-5ubuntu15 0
       500 http://ppa.launchpad.net/bderzhavets/qemu-git/ubuntu/ oneiric/main amd64 Packages
       100 /var/lib/dpkg/status
    0.9.2-4ubuntu15.1 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric-updates/main amd64 Packages
    0.9.2-4ubuntu15 0
       500 http://archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages


reboot the OS
# reboot


check the installed version
# kvm --version
QEMU emulator version 0.15.0 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard

# libvirtd --version
libvirtd (libvirt) 0.9.2

Now you can use SPICE.
virt-manger -> change Display setting from VNC to SPICE


You can change the display from VNC to SPICE by editing *.xml file.

add the following lines.
   <channel type='spicevmc'>
     <target type='virtio' name='com.redhat.spice.0'/>
     <address type='virtio-serial' controller='0' bus='0' port='1'/>
   </channel>


change the following line:

from
<graphics type='vnc' port='-1' autoport='yes'/>

to
<graphics type='spice' autoport='yes' keymap='ja'/>

# diff spice.centos6-1.xml vnc.centos6-1.xml
60,63d59
<     <channel type='spicevmc'>
<       <target type='virtio' name='com.redhat.spice.0'/>
<       <address type='virtio-serial' controller='0' bus='0' port='1'/>
<     </channel>
66c62
<     <graphics type='spice' autoport='yes' keymap='ja'/>
---
>     <graphics type='vnc' port='-1' autoport='yes'/>


start the VM ( CentOS 6.2 )
# LANG=C virsh start centos6-1
Domain centos6-1 started

# ps aux | grep spice
116       7706 13.4  3.1 1381600 389940 ?      Sl   18:26   0:16 /usr/bin/kvm -S -M pc-0.14 -enable-kvm -m 1024 -smp 1,maxcpus=4,sockets=4,cores=1,threads=1 -name centos6-1 -uuid 4cbf3421-bb8e-0d3c-e71b-d8cb29aa588d -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/centos6-1.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=readline -rtc base=utc -boot order=c,menu=on -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/var/disk1/libvirt/images/centos6-1.img,if=none,id=drive-virtio-disk0,boot=on,format=raw -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=20,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:d2:28:33,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -usb -device usb-tablet,id=input0 -spice port=5900,addr=127.0.0.1,disable-ticketing -k ja -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6


connect to the VM via spice-client
virsh # qemu-monitor-command centos6-1 'info spice'
Server:
    address: 127.0.0.1:5900
       auth: none
Channel:
    address: 127.0.0.1:44959
    session: 719885386
    channel: 1:0
Channel:
    address: 127.0.0.1:44960
    session: 719885386
    channel: 4:0
Channel:
    address: 127.0.0.1:44961
    session: 719885386
    channel: 2:0
Channel:
    address: 127.0.0.1:44962
    session: 719885386
    channel: 3:0


on the KVM machine ( Linux Mint ) , start spice client.
$ spicec –h 127.0.0.1 –p 5900