Zen (chữ Z) là cảm giác đỉnh đầu khi đi tiểu trong tuyết sau nhịn 8 tiếng. Xen (chữ X) là công nghệ ảo hóa open-source bạn có thể consider cho setup, home hay business, dù như KVM, oriented corporate market.
Đã có tutorials KVM: intro, setup storage/network (kể bridged networking), resolve conflicts VirtualBox. Bây giờ học Xen. Sẽ show first steps cài/run VMs, terminology tinh tế, GUI/command-line management tools, virtualization modes, appliances, more.

Xen - Giới Thiệu
Short intro Xen internals. Khác hầu hết tech: yêu cầu special kernel boot. Linux system cần separate GRUB menu entry. Boot từ kernel context này -> Xen chạy.
Xen works in layers - domains. Domain đặc quyền nhất: Domain0 (dom0) = hypervisor. Guest OS trên domain này chạy DomainU (domU).
Phức tạp hơn: Xen có 2 modes. Paravirtualization: guest chạy không special calls processor. Full virtualization (Hardware Assisted Virtualization - HVM), phụ thuộc processor virtualization tech (Intel-VT/AMD-V), performance tốt hơn, features mở rộng.
Chi tiết: Xen on Wikipedia, Xen tutorials howtoforge.com
Pros and Cons
Lý do dùng Xen: 1) Free. 2) Robust, mature, powerful CLI syntax dễ script, admin breeze. Quan trọng: không có virtualization tech trong CPU -> vẫn reasonable performance, khác KVM grind to crawl. Nhưng mất functionality paravirtualized. Xem examples sau.
Ngược lại: Xen cumbersome hơn VirtualBox/VMware Server. GUI management cùng dùng cho KVM/Xen, nhưng tạo/cài VM mới difficult hơn với Xen. SUSE integration làm vừa dễ vừa khó. Xem examples sau.
Xen learning curve steep, intimidate less knowledgeable users. Complex architecture, layered management, not-so-simple language -> deter customers, prefer linear simplicity other solutions (single package framework).
Biggest downside: yêu cầu own kernel boot. Khác KVM (insert module vào kernel), Xen phải có GRUB menu entry. Boot vào Xen kernel -> uname khác kernel version.
Test Platform
Xen pre-installed SUSE flavors (openSUSE, SLES) từ 10.3. Use/setup trên distro này fairly simple. Không nghĩa là không dùng Xen trên hệ khác, nhưng may encounter problems. VD: Xen tools Ubuntu repos broken, phải compile từ source. RedHat-based không issue, nhưng preferred tech là KVM.
Nếu dùng Xen, nên start với SUSE, possibly RedHat. Ubuntu friendly nhưng setup pain, không inconceivable.
Bài này show setups trên SUSE 10.3 và 11.2. Future articles: RedHat-based (CentOS, Scientific Linux). Test Xen 3.X. Sắp có Xen 4.0 review (openSUSE 11.4). More goodness coming.
Cài Đặt Xen
Config Xen trên SUSE dễ. YaST > Virtualization > Install Hypervisor and Tools. Setup 2 stages: install packages + change boot menu + boot vào Xen kernel.
Xen cũng auto config bridged networking, neat (default KVM không có). Let finish, reboot.
Basically, done. Ready to use Xen.
Xen Boot Từ GRUB2
Lưu ý: chainload SUSE với GRUB2 -> cần special entry Xen kernel, có thể không auto added by OS probe script. Entry khác standard boot stanzas.
Không đi sâu GRUB2 works (đọc tutorial toàn tập), đây section cần attention. Thay vì linux, initrd entries chuẩn, cần:
multiboot /boot/xen.gz
module /boot/vmlinuz-xen
module /boot/initrd-xen
Adjust exact paths match installations, devices. Screenshot test machine:
Sử Dụng Xen
Khởi động Virtual Machine Manager (VMM), familiar từ KVM tutorials, tạo VM đầu tiên. Warmup: GUI tools, sau đó CLI Xen.
Show 2 setups: 1) SUSE 10, KDE, full virtualization. 2) SUSE 11, Gnome, paravirtualization. Expect mix GUI images.

VMM Running
Rất giống biết rồi:
Tạo Virtual Machine
Tạo VM dùng GUI: launch từ YaST hoặc run vm-create command line. Note: khác VMM + KVM trên Ubuntu (có ability tạo VM từ trong management).
Tùy Chỉnh
Đến summary section, customize gì cần. Click blue title, make changes. VD: Disks section normally point VM image under /var. Thay vào đó, tạo own với dd, đặt anywhere, dùng CD-ROM/ISO images (cần first installation). Screenshots options:
Ready to run.
Chạy Virtual Machine
Tùy config, Virt Viewer (virt-viewer) start hiển thị VM progress. Case: boot Fedora 14 live session.
Status VMM:
Not bad for starters. VM config created on disk, dùng cho understanding Xen syntax và template cho machines khác.
Command Line
Examine Xen lần 2, proper CLI users. Nothing special, nếu dùng KVM -> syntax easy follow. Man pages detailed, good examples.
VM templates under /etc/xen/examples. VM files /etc/xen/vm. Copy over, create machines xm create.
Fedora 14 config:
Important directives:
- builder="hvm" - CPU không support virtualization -> không dùng feature này, set directive linux. Mất functionality.
- boot="d" - Counter-intuitive: d = CD-ROM first, c = disk.
- disk= - Specifies storage. Device order determines seen/used by VM. r/w = read-only/read-write.
Info: read xm man page. Ready use config: xm create
Không muốn config files (testing): create VM on the fly. VD:
xm create /dev/null \
name=Debian \
kernel=/boot/vmlinuz-2.6-xen \
disk=file:/tmp/debian.img,sda1,w \
root=/dev/sda1 memory=256 vcpus=1
Tạo config không write anywhere (/dev/null). Privileged Xen kernel /boot/ (drivers hardware). Hoặc smaller xenU kernel cho paravirtualization. Allocate memory, vCPUs, storage. Set root device.
Cũng có virt-install tạo VM. Interactive mode, hỏi questions, convenient. KVM users familiar syntax.
Other Things
Few more details...
Paravirtualization
Work nhưng big issues. CPU không support virtualization -> Xen uncooperative với functions/options. VD: không boot từ CD paravirtualized mode hầu hết thời gian. Hoặc boot được sau tweaking/fiddling nhiều, mất functionality. Huge minus.
Web reverberating questions/answers: crazy hacks như build HTTP server, mount ISO loopback, pray Mayan gods, few successful/easy. Sẽ discuss riêng. Show cách get going paravirtualization despite odds, explain why không muốn làm vậy.
More Reading
Brave run Xen Ubuntu: Community Documentation.
Xen wiki detailed virtuatopia.com.
Xen management tools - discuss separate articles.
openSUSE Xen page, how to install Xen VM Server.
Blog virtualization worthy: blog.bodhizazen.net, không chỉ Xen.
Kết Luận
Xen không phải monster, dù daunting new users. Infrastructure complicated deterrent. But focus -> không dramatic. Get extra kernels, add bootloader, boot Xen, GUI/CLI tools manage VMs. Trên SUSE, Xen included OS -> easier.
So với KVM: Xen chút phức tạp hơn, nhưng bridged networking từ đầu, no conflict other techs. Paravirtualization (parts work) performance tốt hơn emulation mode KVM. Full virtualization: cả 2 handy/useful. Hy vọng tutorial clear fog.
Sequels: additional management tools Xen, standalone Xen Cloud Platform, live edition. Xen run từ live CD, w00t. Enjoyed. See you around.
Cheers.