[[PageOutline]] {{{ #!html

libvirt

}}} ---- = 【libvirt 介紹】 = * libvirt 支援各種 VMM 程序(Xen, KVM, VirtualBox, Qemu, OpenVZ, UML, LXC...),以提供統一的虛擬化上層管理介面 * libvirt 有兩種運作模式: 1. '''local''': 直接使用 libvirt API [[BR]] [[Image(http://www.ibm.com/developerworks/cn/linux/l-libvirt/figure1.gif)]] 2. '''Remote''': 必須額外啟動 libvirtd 來 remote communication [[BR]] [[Image(http://www.ibm.com/developerworks/linux/library/l-libvirt/figure2.gif)]] * [http://libvirt.org/html/libvirt-libvirt.html libvirt API 主要可分為五種類型:] 1. VMM 連接 API 2. Domain 管理 API 3. 網路管理 API 4. Storage volume API 5. Storage pool API * [http://libvirt.org/bindings.html libvirt API 支援的語言] * python * C/C++ * Ruby * JAVA * perl * variety of scripting languages, and even a unified functional language (Objective caml) * 使用 libvirt 開發的應用 * virt-install * virt-clone * virt-manager * virt-viewer * oVirt ---- = 【libvirt 測試】 = == [安裝] == * [http://libvirt.org/deployment.html 從 source 安裝] {{{ $ wget http://libvirt.org/sources/libvirt-0.8.4.tar.gz ; tar zxvf libvirt-0.8.4.tar.gz ; cd libvirt-0.8.4 $ ./configure --with-xen --prefix=/usr $ make $ make install }}} * configure 遇到缺少某套件時 {{{ $ sudo aptitude install libxml2-dev libgnutls-dev libdevmapper-dev libxen-dev }}} * 從套件檔安裝 {{{ $ aptitude search libvirt p libvirt-bin - the programs for the libvirt library p libvirt-dev - development files for the libvirt library p libvirt-doc - documentation for the libvirt library p libvirt-ocaml - OCaml bindings for libvirt p libvirt-ocaml-dev - OCaml bindings for libvirt p libvirt0 - library for interfacing with different virtualization system p libvirt0-dbg - library for interfacing with different virtualization system p python-libvirt - libvirt Python bindings v python2.5-libvirt - }}} == [操作] == * 使用 virsh (虛擬 shell,基於 shell 的互動方式操作) {{{ # virsh create xen-vm01.xml (設定檔為 xml 格式) # virsh list # virsh suspend 1 # virsh resume 1 }}} == [使用 API] == ---- = 【References】 = * [http://libvirt.org/ libvirt 官網] * [http://www.ibm.com/developerworks/cn/linux/l-libvirt/ Libvirt 虛擬化庫解析] * [http://l10n.ubuntu.tla.ro/ubuntu-8.10/html/serverguide/zh_CN/libvirt.html Ubuntu 關於 libvirt 的介紹] * [http://wiki.debian.org/libvirt Debian 關於 libvirt 的介紹] * 安裝&配置 * [http://bderzhavets.wordpress.com/2010/05/18/set-up-libvirt-0-7-7xen-4-0-on-top-fedora-13-rc2/ Set up Libvirt 0.7.7&Xen 4.0 Dom0 (2.6.32.13 pvops) on top of Fedora 13 RC2] * [http://blog.penumbra.be/2010/02/xen-libvirt-debian-lenny/ Install Xen and libvirt on Debian Lenny] * [http://edin.no-ip.com/content/libvirt-kvm-debian-mini-howto libvirt + KVM on Debian mini-HOWTO] * Xen * [http://blog.csdn.net/guxn25/archive/2008/05/25/2479745.aspx 基于libvirt API监测xen初探] * KVM * [http://heprc.phys.uvic.ca/sites/heprc.phys.uvic.ca/files/reports/vliet-wtr.pdf Creating and Controlling KVM Guests using libvirt]