虚拟机器启动的配置文件例子

来源:互联网 发布:国内数据交易平台 编辑:程序博客网 时间:2024/05/17 08:17

全虚:

acpi=1

device_model='/usr/lib/xen/bin/qemu-dm'
serial='pty'
localtime=1
boot='d'
kernel='/usr/lib/xen/boot/hvmloader'
acpi=1
device_model='/usr/lib/xen/bin/qemu-dm'
serial='pty'
localtime=1
boot='d'
kernel='/usr/lib/xen/boot/hvmloader'
vncunused=1
keymap='en-us'
maxmem=2048
memory=2048
on_crash='destroy'
vnc=1
on_poweroff='destroy'
usbdevice='tablet'
builder='hvm'
description='wwwwwwwwwwwwwwwwwwwwwww'
uuid='082df39a-53f4-9c96-36b7-fc8997424197'
usb=1
on_reboot='destroy'
pae=1
disk=['phy:/dev/iwmvg/winps,hda,w', 'file:/data2/ISOs/WinOS/en_windows_server_2003_with_sp1_enterprise.iso,hdc:cdrom,r']
vif=['mac=00:16:3e:16:b9:92,bridge=br0,model=rtl8139']
stdvga=0
vcpus=2
extid=0

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

View Code BASH
1234567891011121314151617181920212223242526272829
# =====================================================================# Example PV Linux guest configuration# ===================================================================== # Guest namename = "jay-pvlinux" # Kernel image to bootkernel = "/boot/vmlinuz-xen" # Ramdisk (optional)ramdisk = "/boot/initrd-xen.img" # Kernel command line optionsextra = "root=/dev/xvda1" # Initial memory allocation (MB)memory = 1024 # Number of VCPUSvcpus = 2 # Network devicesvif = [ '' ] # Disk Devicesdisk = [ '/root/jay/ia32e_rhel6u2.img,raw,xvda,rw' ] vfb = [ 'vnc=1,vncpass=' ]

第2种配置文件:xlexample.pygrub
它的特色就是有bootloader = “/usr/bin/pygrub”的配置,而没有了”kernel=”这样的配置。

View Code BASH
12345678910111213141516171819202122
# =====================================================================# Example PV Linux guest configuration# ===================================================================== bootloader = "/usr/bin/pygrub" # Guest namename = "jay-pvlinux" # Initial memory allocation (MB)memory = 1024 # Number of VCPUSvcpus = 2 # Network devicesvif = [ '' ] # Disk Devicesdisk = [ '/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怎么编译的呢,需要等到今后的博客再简单写一下吧。

View Code BASH
12345678910111213141516171819202122232425
# =====================================================================# Example PV Linux guest configuration# ===================================================================== # Guest namename = "jay-pvlinux" # pv-grub herekernel = "/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 VCPUSvcpus = 2 # Network devicesvif = [ '' ] # Disk Devicesdisk = [ '/root/jay/ia32e_rhel6u2.img,raw,xvda,rw' ] vfb = [ 'vnc=1,vncpass=' ]

对于以上3个PV guest的config文件,都可以用同样的命令创建guest、连接guest的串口、连接guest的vnc(我都加了VNC的配置)。

View Code BASH
1234567
[root@jay-linux jay]# xl create xlexample.pvlinux[root@jay-linux jay]# xl listName                                        ID   Mem VCPUs      State   Time(s)Domain-0                                     0  2048    32     r-----   20422.1jay-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信息,检查里面可能有如下类似关键信息:

View Code BASH
123456789
..............[    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