全虚:
acpi=1
device_model='/usr/lib/xen/bin/qemu-dm'name='Win2k3sp2'
name="ceshi"
description="for ceshi "
uuid="4c64ded6-66cf-696f-2ab0-2777e12b4ac9"
memory=2048
maxmem=2048
vcpus=4
on_poweroff="destroy"
on_reboot="destroy"
on_crash="destroy"
localtime=0
keymap="en-us"
builder="hvm"
device_model="/usr/lib/xen/bin/qemu-dm"
kernel="/usr/lib/xen/boot/hvmloader"
boot="d"
disk=[ 'phy:/dev/iwmvg/ncmlv,hda,w', 'file:/data2/ISOs/SLES-11-SP1-DVD-i586-GM-DVD1.iso,hdc:cdrom,r', ]
vif=[ 'mac=00:16:3e:1b:5f:43,bridge=br0,model=rtl8139', ]
半虚:
name="SLES_11"
description=" server "
uuid="608e5fb9-c0e5-eca4-4bca-ee48fe2ab472"
memory=512
maxmem=512
vcpus=4
on_poweroff="destroy"
on_reboot="restart"
on_crash="destroy"
localtime=0
keymap="en-us"
builder="linux"
bootloader="/usr/bin/pygrub"
bootargs=""
extra=" "
disk=[ 'file:/var/lib/xen/images/SLES_11/disk0.raw,xvda,w', 'file:/data/install/ISOs/SLE-11-x86_64.iso,xvdb:cdrom,r', ]
vif=[ 'mac=00:16:3e:6d:88:7d,bridge=br0', ]
vfb=['type=vnc,vncunused=1']
extra=' mem=1024M'
localtime=0
keymap='en-us'
maxmem=1024
memory=512
on_crash='destroy'
bootargs='--entry=xvda2:/boot/vmlinuz-xen,/boot/initrd-xen'
on_poweroff='destroy'
builder='linux'
description='on sles10 sp3 x64'
uuid='5c74857e-001a-13b7-4d13-8e496412c37b'
on_reboot='restart'
vif=['mac=00:16:3e:1f:22:e5,bridge=br0', 'mac=00:16:3e:5d:9a:dd,bridge=br1']
bootloader='/usr/lib/xen/boot/domUloader.py'
disk=['file:/data2/ISOs/SLES-10-SP3-DVD-x86_64-GM-DVD1.iso,xvdb:cdrom,r', 'file:/var/lib/xen/images/sles10-sp3-x86_64/disk0.raw,xvda,w']
vcpus=4
vfb=['vncunused=1,type=vnc']
name='-testing'
The pygrub bootloader is not available on the SUSE platform. Instead, there is a domUloader.py located at /usr/lib/xen/boot directory. Once the installation of PV images is complete, you would have to change the bootloader manually to /usr/lib/xen/boot/domUloader.py. Also, the bootloader requires bootargs param containing the location of path to kernel and ramdisk within the VM image. The bootargs can be specified in the Miscellaneous tab. Here is an exmple entry :
bootargs =--entry=xvda1:/vmlinuz,/initrd.img
Note: The domUloader is not able to mount the rPath Appliance images. This prevents it from being able to fetch the kernel and ramdisk from the appliance and start it. We would publish a set of steps once the domUloader issue is resolved.
ramdisk='/etc/xen/i586/initrd-2.6.27.19-5-xen'
extra=' mem=4096M'
localtime=0
kernel='/etc/xen/i586/vmlinuz-2.6.27.19-5-xen'
keymap='en-us'
maxmem=4096
memory=2048
on_crash='destroy'
on_poweroff='destroy'
builder='linux'
description='www'
uuid='a26dcac6-cbe6-f044-37d6-d3d1625b73a2'
on_reboot='restart'
#vif=['mac=00:16:3e:51:e1:9e,bridge=br0', 'mac=00:16:3e:52:e1:9e,bridge=br1']
vif=['mac=00:16:3e:51:e1:9e,ip=10.0.0.1', ]
disk=['phy:/dev/sda3,xvda2,w', 'phy:/dev/sda6,xvda1,w']
vcpus=8
vfb=['vncunused=1,type=vnc']
name='www'
经过研究发现,目前最新的Xen 4.x中,PV guest的配置方式大约是有3方式:
1. 传统的也是最流行和推荐的:kernel和initrd放在Dom0中的;
2. 使用pygrub启动
3. 使用pv-grub启动
第1种,是Xen很早就支持的方式了;而第2、3种都是后来加上去的方式,它们的guest kernel都在guest image中,不受Dom0的影响,它们的好处是PV guest相对独立,guest升级kernel可以不受Dom0的影响。
你可能需要了解的基本概念有以下几点:
a. 对于第1种方式,是说kernel放在dom0中,但并不是要和dom0同一个kernel,也可以是另外自己编译的kernel(注意:需要在dom0的/lib/modules/下面有你配置的PV guest kernel所对应的modules文件);
b. 第1种方式中,PV guest启动的kernel和加载的module都是存放在dom0中的。
c. pygrub是Xen提供的一个userspace的Bootloader工具,它是为了实现从domU中存放的kernel启动PV guest,而不需要用在dom0中存放的kernel。
d. 而pv-grub的出现是为了取代pygrub的,它提供一种更为安全的方式去启动PV guest,它需要一个mini的OS(名字可能为:pv-grub-x86_32.gz)。
e. 不管使用哪种方式,由于是PV guest,所以他们的kernel都是经过特殊配置的,比如一些重要的config项目有:CONFIG_XEN=y, CONFIG_XEN_DEBUG_FS=y, CONFIG_PCI_XEN=y, CONFIG_XEN_PCIDEV_FRONTEND=y, CONFIG_XEN_BLKDEV_FRONTEND=y, CONFIG_XEN_NETDEV_FRONTEND=y 等等(当然部分配置为module而不是编译进kernel也是可以的)。
第1种配置文件:xlexample.pvlinux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# ===================================================================== # Example PV Linux guest configuration # ===================================================================== # Guest name name = "jay-pvlinux" # Kernel image to boot kernel = "/boot/vmlinuz-xen" # Ramdisk (optional) ramdisk = "/boot/initrd-xen.img" # Kernel command line options extra = "root=/dev/xvda1" # Initial memory allocation (MB) memory = 1024 # Number of VCPUS vcpus = 2 # Network devices vif = [ '' ] # Disk Devices disk = [ '/root/jay/ia32e_rhel6u2.img,raw,xvda,rw' ] vfb = [ 'vnc=1,vncpass=' ] |
第2种配置文件:xlexample.pygrub
它的特色就是有bootloader = “/usr/bin/pygrub”的配置,而没有了”kernel=”这样的配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# ===================================================================== # Example PV Linux guest configuration # ===================================================================== bootloader = "/usr/bin/pygrub" # Guest name name = "jay-pvlinux" # Initial memory allocation (MB) memory = 1024 # Number of VCPUS vcpus = 2 # Network devices vif = [ '' ] # Disk Devices disk = [ '/root/jay/ia32e_rhel6u2.img,raw,xvda,rw' ] vfb = [ 'vnc=1,vncpass=' ] |
第3种配置文件:xlexample.pvgrub
注意,其中extra = “(hd0,0)/boot/grub/grub.conf” 指的是guest中grub.conf的位置。
而关于,pv-grub-x86_32.gz怎么编译的呢,需要等到今后的博客再简单写一下吧。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# ===================================================================== # Example PV Linux guest configuration # ===================================================================== # Guest name name = "jay-pvlinux" # pv-grub here kernel = "/usr/lib/xen/boot/pv-grub-x86_32.gz" extra = "(hd0,0)/boot/grub/grub.conf" # pv-grub end # Initial memory allocation (MB) memory = 1024 # Number of VCPUS vcpus = 2 # Network devices vif = [ '' ] # Disk Devices disk = [ '/root/jay/ia32e_rhel6u2.img,raw,xvda,rw' ] vfb = [ 'vnc=1,vncpass=' ] |
对于以上3个PV guest的config文件,都可以用同样的命令创建guest、连接guest的串口、连接guest的vnc(我都加了VNC的配置)。
1 2 3 4 5 6 7 |
[root@jay-linux jay]# xl create xlexample.pvlinux [root@jay-linux jay]# xl list Name ID Mem VCPUs State Time(s) Domain-0 0 2048 32 r----- 20422.1 jay-pvlinux 56 512 2 -b---- 19.8 [root@jay-linux jay]# xl console 56 [root@jay-linux jay]# xl vnc 56 |
怎么检查一个guest里面是运行的PV guest而不是HVM guest呢?
可以检查guest的dmesg信息,检查里面可能有如下类似关键信息:
1 2 3 4 5 6 7 8 9 |
.............. [ 0.000000] Booting paravirtualized kernel on Xen [ 0.000000] Xen version: 4.2-unstable (preserve-AD) .............. [ 0.028998] PCI: setting up Xen PCI frontend stub .............. [ 0.205180] Initialising Xen virtual ethernet driver. [ 0.206173] blkfront: xvda: barrier: enabled .............. |
更多关于pygrub、pv-grub的参考资料如下:
http://wiki.xen.org/wiki/PyGrub
http://wiki.xen.org/wiki/PvGrub
http://wiki.xen.org/wiki/PVGrub_HowTo