5. sean666666@gmail.com P5
Guest domain status
State Description
Undefine
d
This is the baseline state. An undefined guest domain has not been
defined or created in any way.
Defined A defined guest domain has been defined but is not running. This
state could also be described as Stopped.
Running A running guest domain is defined and being executed on a hypervisor.
Paused A paused guest domain is in a suspended state from the Running
state. Its memory image has been temporarily stored, and it can be
resumed to the Running state without the guest domain operating
system being aware it was ever suspended.
Saved A saved domain has had its memory image, as captured in the
Paused state, saved to persistent storage. It can be restored to the
Running state without the guest domain operating system being
aware it was ever suspended.
10. sean666666@gmail.com P10
xm
• Xen management user
interface
• The xm program is the main
interface for managing Xen
guest domains. The program
can be used to create, pause,
and shutdown domains. It can
also be used to list current
domains, enable or pin
VCPUs, and attach or detach
virtual block devices.
• Example
o xm create Fedora12
o xm start Fedora12
o xm help
o xm list
o xm mem-set {domain-id,
mem}
o xm migrate {domain-id,
host-ip}
o etc…沒事多玩指令,多
玩指令沒事
14. sean666666@gmail.com P14
Libvirt(http://libvirt.org/index.html)
• A toolkit to interact with the virtualization
capabilities of recent versions of Linux (and
other OSes), see our project goals for details.
• Free software available under the GNU Lesser
General Public License.(LGPL)
• A long term stable C API
• A set of bindings for common languages.(Java、
Python…etc)
• Latest release: 0.8.8: Feb 17 2011
15. sean666666@gmail.com P15
Terminology and goals
Xen
…
一般稱呼 Libvirt的術語 解釋
VM Domain An instance of an operating system (or
subsystem in the case of container
virtualization) running on a virtualized machine
provided by the hypervisor
Xen Hypervisor A layer of software allowing to virtualize a
node in a set of virtual machines with possibly
different configurations than the node itself
Physical
machine
Node A single physical machine
16. sean666666@gmail.com P16
Libvirt drivers
• Hypervisor drivers
o LXC - Linux Containers
o OpenVZ
o QEMU
o Test - Used for testing
o UML - User Mode Linux
o VirtualBox
o VMware ESX
o VMware
Workstation/Player
o Xen
o 支援Multi-Vendor(表面上…)
• Storage drivers
o Directory backend
o Local filesystem backend
o Network filesystem backend
o Logical Volume Manager
(LVM) backend
o Disk backend
o iSCSI backend
o SCSI backend
o Multipath backend
25. sean666666@gmail.com P25
Debug / loggin
• Log message
o Generated at runtime by the libvirt code
o Timestamp, a category, a priority level, function name and line number indicating
where the message originated from, and a formatted message.
• Priority levels
o 1 (or debug) - log all messages
o 2 (or info) - log all non-debugging information
o 3 (or warn) - log only warnings and errors - this is the default
o 4 (or error) - log only errors
• Filter
o x:name
o 1:qemu
o 1:qemu 4:remote
• Log output
o 3:syslog:libvirtd 1:file:/tmp/libvirt.log
26. sean666666@gmail.com P26
虛擬裝置也支援熱插拔嗎?
• 半虛擬技術支援在不開機的情況下,CPU、MEM、DISK
都可以做調整。
• 全虛擬CPU、MEM要調整一定得重開機。
• 全虛擬DISK熱插拔則視VM的kernel版本而定。
• The Xen device model is more or less unchanged in the pv-ops
kernel. Converting a driver from the xen-unstable or 2.6.18-xen tree
should mostly be a matter of getting it to compile. There have been
changes in the Linux device model between 2.6.18 and 2.6.26, so
converting a driver will mostly be a matter of forward-porting to the
new kernel, rather than any Xen specific issues.
• Kernel version > 2.6.26 可能比較穩定有機會實現全虛擬的硬碟熱插
拔。
27. sean666666@gmail.com P27
Xen disk kinds and supporting
• Disk type
o IDE
o Virtual disk
o iSCSI
o USB Disk
• 實測熱插拔
xen 4.0 + 2.6.32.11
/ Dell
Storage
IDE Virtual SCSI USB Disk
centos5.4final
Kernel 2.6.18
× ○ × ×
RH6beta
Kernel 2.6.18
× × × ×
28. sean666666@gmail.com P28
API Issues
• create 跟 define 有什麼不同?
o 都是用來創建VM的API
o 差別在生命週期不完全相同
o create: 創建VM之外,順便把VM開起來,shutdown後該VM自動
從hypervisor卸除。
o define: 僅創建VM,須靠start API把VM開起來,但永遠定義在
hypervisor裡。甚至連migrate後也在。
• shutdown 跟 destroy 有什麼不同?
o 都是要把VM的狀態從running改成stop
o Shutdown:就是一般作業系統的關機。
o Destroy:以實體主機來看,就是直接把插頭拔掉。
35. sean666666@gmail.com P35
DEMO
• 準備 VM
o define
o create
• 操作 VM
o start
o suspend
o resume
o reboot
o shutdown
• 添加/卸載設備
o attach
o detach
• 取得 VM
o lookupByXXX
• 跨主機(下回分曉…)
o virtManager 介紹
o migration
o live migration
36. sean666666@gmail.com P36
Thank you
• 末記
o 這份資料的技術實作於2010~2011,如非最新資料,敬
請見諒
• End
o The technology information was implemented in 2010 ~
2011, sorry for no update on time.