Xen与KVM的比较
Xen也是Linux下的一个虚拟化解决方案,也将很快被编入内核中。Xen的实现方法是,运行支持Xen功能的kernel,这个kernel是工作在Xen的控制之下,叫做Domain0,使用这个 kernel启动机器后,你可以在这个机器上使用qemu软件,虚拟出多个系统。Xen的缺点是,如果你需要更新Xen的版本,你需要重新编译整个内核,而且,稍有设置不慎,系统就无法启动。
相比较,KVM就简化的多了。它不需要重新编译内核,也不需要对当前kernel做任何修改,它只是几个可以动态加载的.ko模块。它结构更加精简、代码量更小,所以,出错的可能性更小。并且在某些方面,性能比Xen更胜一筹。
不难看出,xen和KVM是linux下两个重要的虚拟化解决方案。xen的工作方式是直接修改kernel,变成一个xen kernel,也就是Domain 0.然后在这个Domain 0的控制下虚拟出多个Domain u的方式,可以看出这种方式其实是在kernel与硬件之间加了一个xen控制层,来实现虚拟化。Virtual machines are created by a software layer called the virtual machine monitor (VMM)。linus对于这种方法看来很抵触。而kvm的实现方法却有所不同,它首先是需要CPU虚拟功能的支持,本身是以模块的形式加入到 kernel中,你可以把KVM理解为一个绿色软件。KVM是后起之秀,在目前的功能和应用上还远不及Xen,不过可以预见,不久的将来,以及各大厂商, 特别是intel对于虚拟化的重视,虚拟化的实现更多依赖于CPU,KVM的简洁和绿色将会更加成功。
Name
virt-install - provision new virtual machines
Synopsis virt-install [ OPTION ]...
-m MAC , --mac=MACFixed MAC address for the guest; If this parameter is omitted, or the value "RANDOM" is specified a suitable address will be randomly generated. For Xen virtual machines it is required that the first 3 pairs in the MAC address be the sequence '00:16:3e', while for QEMU or KVM virtual machines it must be '54:52:00'.-b BRIDGE , --bridge=BRIDGEBridge device to connect the guest NIC to. This parameter is deprecated in favour of the "--network" parameter.-w NETWORK , --network=NETWORKConnect the guest to the host network. The value for "NETWORK" can take one of 3 formats:bridge:BRIDGEConnect to a bridge device in the host called "BRIDGE". Use this option if the host has static networking config & the guest requires full outbound and inbound connectivity to/from the LAN . Also use this if live migration will be used with this guest.network:NAMEConnect to a virtual network in the host called "NAME". Virtual networks can be listed, created, deleted using the "virsh" command line tool. In an unmodified install of "libvirt" there is usually a virtual network with a name of "default". Use a virtual network if the host has dynamic networking (eg NetworkManager), or using wireless. The guest will be NATed to the LAN by whichever connection is active.userConnect to the LAN using SLIRP . Only use this if running a QEMU guest as an unprivileged user. This provides a very limited form of NAT .If this option is omitted a single NIC will be created in the guest. If there is a bridge device in the host with a physical interface enslaved, that will be used for connectivity. Failing that, the virtual network called "default" will be used. This option can be specified multiple times to setup more than one NIC . Examples
Install a paravirtualized Xen guest, 500 MB of RAM , a 5 GB of disk, and Fedora Core 6 from a web server, in text-only mode:
Install a KVM guest, using LVM partition, virtual networking, booting from the host CDROM , using VNC server/viewer
# virt-install \
--connect qemu:///system \
--name demo
--ram 500 \
--file /dev/HostVG/DemoVM \
--network network:default \
--accelerate \
--vnc \
--cdrom /dev/cdrom
Run a Live CD image under Xen fullyvirt, in diskless environment
# virt-install \
--hvm \
--name demo \
--ram 500 \
--nodisk \
--livecd \
--vnc \
--cdrom /root/fedora7live.iso
==================
To create a CentOS 5.2 guest (in bridging mode) with the name vm10, 512MB of RAM, two virtual CPUs, and the disk image ~/vm10.qcow2 (with a> sudo virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c /dev/cdrom --vnc --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm
Of course, you can also create an ISO image of the CentOS DVD... sudo dd if=/dev/cdrom of=~/CentOS-5.2-x86_64-bin-DVD.iso
... and use the ISO image in the virt-install command:
sudo virt-install --connect qemu:///system -n vm10 -r 512 --vcpus=2 -f ~/vm10.qcow2 -s 12 -c ~/CentOS-5.2-x86_64-bin-DVD.iso --vnc --noautoconsole --os-type linux --accelerate --network=bridge:br0 --hvm