最後更新: 2020-10-18
介紹
Spice server is implemented in libspice(a VDI pluggable library)
(VDI = Virtual Device Interfaces (VDI))
VDI: defines a set of interfaces that provide a standard way to publish virtual devices
(e.g. display device, keyboard, mouse)
(QEMU)Spice Server(libspice) <-Spice protocol-> Spice Client(remote-viewer ) | QXL Device VDI Port Device VM QXL Drivers Spice Agent
功能
- Encryption - Using TLS
- Live migration
- Hardware cursor - processes and transmits cursor-specific commands
- Image, palette and cursor caching - manages client caches to reduce bandwidth requirements
- Windows drivers - Windows drivers for QXL display device and VDI-port
- Image compression(QUIC, LZ, GLZ(history-based global dictionary), auto(heuristic compression choice per image))
- Video streaming - heuristically identifies video streams and transmits M-JPEG video streams
- Graphic commands - processes and transmits 2D graphic commands
- Lip-sync - synchronizes video streams with audio clocks
- Clipboard sharing, drag and drop files between OS
- Folder sharing
- higher resolutions, multiple monitors, resizing to arbitrary resolutions
- USB redirection
- SASL authentication
- Web client - WebSockets + javacript client
Homepage: http://spice-space.org/
Video XML
<video> <model type='vga' vram='9216' heads='1'/> <acceleration accel3d='yes' accel2d='yes'/> </video>
* 當沒有設定 video 的 xml 時, libvirt 會自動加上 default 的 device
Spice
Diagram
| QXL Device | VDI Port | | KVM | |-----------------------| | QXL Driver | VDI Agent| | Guest OS |
Installation
Centos Install
yum install spice-client
ubuntu 12.04:
- qemu-kvm-spice - Full virtualization on amd64 hardware <-- VM hosts
- spice-client - Implements the client side of the SPICE protocol <-- Admin PC
- spice-client-gtk - Simple clients for interacting with SPICE servers
- spice-vdagent - Spice agent for Linux <-- VM Guest
Window download:
Remote viewer
https://virt-manager.org/download/
UsbDk - A Windows filter driver developed for Spice USB redirection (windows client side)
https://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.22_x64.msi
https://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.22_x86.msi
Agent
This includes the qxl video driver and the SPICE guest agent
https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe
Spice server in qemu-kvm
# not require authentication and simply bind the server to 127.0.0.1 on port 5900.
/usr/bin/qemu-kvm ... -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing
Type
"vga", "cirrus", "vmvga", "xen", "vbox", or "qxl"
Libvirt Setting
Server Setting
/etc/libvirt/qemu.conf
spice_listen = "0.0.0.0" spice_password = "XYZ12345"
systemctl restart libvirtd
Guest XML
<graphics type='spice'/> <video> <model type='qxl'/> </video>
指定 Port
<graphics type='spice' port='5932' autoport='no' listen='192.168.123.10'/>
設定 Password
<graphics type='spice' passwd='mysecretpassword'/>
Guest Start 後
virsh # domdisplay win7
spice://192.168.123.10:5932
Guest Agent
Guest side software: QXL driver and SPICE VDAgent
The Guest side is all the software that must be running in the VM in order to make SPICE fully functional
# spice agent communication channel
-device virtio-serial-pci \ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \ -chardev spicevmc,id=spicechannel0,name=vdagent
Install the spice vdagent in guest
# Centos 6
yum install spice-vdagent
chkconfig --add spice-vdagentd
service start spice-vdagentd
Guest XML
<devices> <controller type='virtio-serial' index='0'/> <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> </channel> </devices>
Usage
# Linux
spicec -h IP [-p PORT] [-w PW]
# Win
remote-viewer spice://myhost:port
Folder sharing
<devices> <channel type='spiceport'> <source channel='org.spice-space.webdav.0'/> <target type='virtio' name='org.spice-space.webdav.0'/> </channel> </devices>
Recording/replaying SPICE server traffic
spice-server-replay -p 5900 -c "remote-viewer spice://localhost:5900" recorded-session.spice
TLS
# Enable TLS
spice_tls = 1
# ca-cert.pem - the CA master certificate
# server-cert.pem - the server certificate signed with ca-cert.pem
# server-key.pem - the server private key
# dh-params.pem - the DH params configuration file
spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice"