虛擬化技術學習(二)Unbuntu下SPICE的配置
最近一直搞spice,安裝了就費了我好久時間,在網上看別人的一些教程都是說參看官方教程 http://docs.cslabs.clarkson.edu/wiki/SPICE 但是進教程一看,發現內容已經被刪除了,經過我的不懈努力還是找到了一篇應該是從官方教程翻譯出來的教程.http://www.verydemo.com/cj.jsp?c=59&u=ubuntu-xia-spice-de-an-zhuang-yu-pei-zhi
然後我就按著教程一步一步的安裝,但是在中間總是出現了一些錯誤,最後總是沒能全部安裝好.我也來做一次搬運工吧.搬運一些官方教程上面的步驟.
SPICE主要包括三部分:SPICE protocol (協議)、SPICE Client(用戶端) 、SPICE Server(服務端)
協議是服務端與用戶端通訊的基礎, 用戶端是享受服務的終端機器, 服務端是提供服務的後台機器。
0. 安裝前預備工作: 由於要從git 伺服器下載源碼安裝,所以需要安轉git工具
sudo apt-get install build-essential autoconf git-core
當然,還有編譯安裝包使用的工具也要安裝:
sudo apt-get install libtool liblog4cpp5-dev libavcodec-dev libssl-dev xlibmesa-glu-dev libasound-dev libpng12-dev libfreetype6-dev \libfontconfig1-dev libogg-dev libxrandr-dev kvm libgcrypt-dev libsdl-dev libnss3-dev libpixman-1-dev libxfixes-dev libjpeg8-dev \libsasl2-dev python-pyparsing
最後準備,建立一個檔案夾,用來存放下載的安裝包(如果你對下載安裝位置很清楚,當然也可以不用建立這個檔案夾)
cdmkdir spice-sourcescd spice-sources
1. SPICE安裝依賴包:
1.1 libcacardThis library is what SPICE uses to emulate smart cards and smart card readers.
git clone git://people.freedesktop.org/~alon/libcacardcd libcacard./autogen.shmakesudo make installcd ..
1.2. 安裝協議(SPICE protocol headers)The first dependency to install is the spice protocol headers.
wget http://spice-space.org/download/releases/spice-protocol-0.8.0.tar.bz2tar xjvf spice-protocol-0.8.0.tar.bz2cd spice-protocol-0.8.0mkdir m4./configuremakesudo make installcd ..
1.3.安裝celtSPICE requires a specific version of the celt low-latency audio codec (0.5.1.3). Since it is unavailable in the Ubuntu repositories, it must also be compiled.
wget http://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gztar xvzf celt-0.5.1.3.tar.gzcd celt-0.5.1.3/./configuremakesudo make installcd ..
2. 安裝用戶端(SPICE client)This gives us spicec, the spice client. It's used to connect to SPICE guests. 用戶端用來連結服務端的。
wget http://spice-space.org/download/releases/spice-0.8.1.tar.bz2tar xjvf spice-0.8.1.tar.bz2cd spice-0.8.1./configure --enable-smartcardmakesudo make installcd ..
This step is possible to perform on a 32-bit host; it's only installing the SPICE client. 值得注意的是:32位系統只能安裝SPICE 的用戶端,下面的服務端是無法安裝的!
3. 安裝SPICE serverNow, it's time to build the SPICE server itself. SPICE has been rolled into QEMU now, so this step amounts to installing a recent version of QEMU. In fact, we will be pulling the latest QEMU source code for version 0.14. Oddly enough, QEMU 0.14 is available in the Ubuntu repositories, but SPICE support is not included in the build. 以上的意思是說QEMU已經包含 SPICE服務,
First, we need to change an environment variable so that ./configure can find the spice protocol libraries we installed. You will need to set this variable anytime you want to use qemu with SPICE, so it's easiest to put it in your .bashrc. 修改環境變數以至於讓configure找到我們安裝spice協議的函數庫。
echo "export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}" >> ~/.bashrcsource ~/.bashrcNow, we can continue with the installation. Note that if you require a specific softmmu target, you can add a list of them with the --target argument. By default, QEMU only builds with support for 32-bit x86 guests. 繼續安裝,(PS:如果在之前已經安裝過QEMU的話,這一步可以省略)
wget http://download.savannah.gnu.org/releases/qemu/qemu-0.14.0.tar.gztar xzvf qemu-0.14.0.tar.gzcd qemu-0.14.0./configure --enable-spice --enable-kvm --enable-io-thread --audio-drv-list=alsa,oss --enable-systemmakesudo make install
Now, we need to copy over some BIOS files that qemu will need to start SPICE VMs. We just need to put them in a location that QEMU expects them to be. 拷貝相關檔案到QEMU 目錄下讓qemu啟動虛擬機器。(PS:如果之前已經安裝QEMU,此步只需確認在/usr/share/qemu/目錄下有以下兩個檔案即可,如果沒有,那就得手動拷貝過去)
sudo cp pc-bios/vgabios-qxl.bin /usr/share/qemu/ sudo cp pc-bios/pxe-e1000.bin /usr/share/qemu/ cd ..
Now, qemu with SPICE support is installed in /usr/local/bin, and the ordinary system qemu is installed in/usr/bin. We'll make a shortcut command called 'qemu-spice' that you can invoke separately from the system qemu (which doesn't have SPICE support). 以上將含有SPICE 服務的QEMU安裝到usr/local/bin(PS:也可能在usr/bin下),普通 QEMU 系統安裝在/usr/bin下。以下是建立一個名字叫做qemu-spice的工具,其實是qemu的一個拷貝。
cd /usr/local/binsudo mv qemu qemu-spice
至此,server安裝完畢。
4.使用SPICE4.1使用ClientTo invoke the spice client, use the command:調用用戶端,使用如下命令 注意:<server hostname> 是伺服器的地址,如果你的電腦同時安裝客戶服務端,那麼你可以使用127.0.0.1來自己測試,<port number> 是服務端制定的連接埠號碼
spicec -h <server hostname> -p <port number>
4.2 使用ServerInvoking the spice server is rather more complex than the client, since you have to set the parameters of the virtualized guest. For example, 調用Server要比用戶端麻煩得多。
qemu-spice -spice port=5930,disable-ticketing -drive file=/path/to/image -vga qxl -device AC97 -usbdevice tablet -m 1024 -enable-kvm -net nic -net user
注意:file=/path/to/image 要替換為系統的鏡像檔案,比如我的file=/kvm/vdisk.img
這樣就啟動了SPICE 服務端,然後在客戶機上使用用戶端命令
spicec -h <server hostname> -p <port number>
就可以在SPICE用戶端啟動服務機上的虛擬機器系統了。 檔案,比如我的file=/kvm/vdisk.img
以上是教程裡面的安裝過程.
經過以上的安裝過程之後.我們來查看一下已經安裝了哪些和spice有關的packages.
我們輸入
dpkg --get-selections | grep spice
可能會有一些內容沒安裝好,下面是全部安裝好的.
我第一次安裝的時候,發現裡面很多東西都沒有安裝好,然後我就直接用 sudo apt-get install 這個命令,安裝裡面沒有的packages.
然後我們就可以在kvm中安裝虛擬機器了,可以參看之前的部落格 http://blog.csdn.net/whjkm/article/details/40587955
在kvm中安裝spice請參看下一篇部落格~