A summary about creation of kinds of xen domU

Since have worked on xen tests for some time, I decide to do a summary
of domU configurations about how to create xen domUs with xm &
vir-install. In order to use it as a quick reference, all the examples listed
below have been verified on my machine.

1) Create a solaris nevada PV domU with iso image by xm

bash-3.2# cat snv_pv.py
name = "solaris-pv"
memory = "800"
disk = [ 'file:/net/bounty/ftp/pub/CDimages/nv/76/x86/solarisdvd.iso,6,r', 'phy:/dev/dsk/c2d0s5,0,w' ]
on_shutdown = "destroy"
on_reboot = "destroy"
on_crash = "destroy"

2) Jumpstart net install a solaris nevada PV domU by xm
bash-3.2# cat snv_jump.py
name = "solaris-pv"
memory = "1024"
vif = [ 'mac=aa:ff:bb:aa:27:17' ]
kernel = "/net/bounty/export/nv/x/latest/boot/platform/i86xpv/kernel/amd64/unix"
ramdisk = "/net/bounty/export/nv/x/latest/boot/amd64/x86.miniroot"
disk = [ 'file:/export/xen_test/snv76_pv.img,0,w' ]
extra = "/platform/i86xpv/kernel/amd64/unix - install -B router-ip=10.13.21.254,
    install_media=10.13.32.48:/export/nv/x/latest,
    install_config=129.158.218.84:/work/jumpstart_domU,
    sysid_config=129.158.218.84:/work/jumpstart_domU,
    host-ip=10.13.21.150,boot-mac=aa:ff:bb:aa:27:17"
on_shutdown = "destroy"
on_reboot = "destroy"
on_crash = "destroy"

3) Create a linux PV domU by xm
bash-3.2# lofiadm -a /net/greatwall.prc/workspaces/xen-test/domUs/CentOS-5.0-x86_64-bin-DVD.iso
/dev/lofi/1
bash-3.2# mount -Fhsfs /dev/lofi/1 /mnt
bash-3.2# share /mnt

bash-3.2# cat Install_centos.py
name = "centos5-install"
memory = "512"
kernel = "/mnt/images/xen/vmlinuz"
ramdisk = "/mnt/images/xen/initrd.img"
extra = "headless ip=dhcp method=nfs:129.158.218.44:/mnt lang=en_US keymap=us ksdevice=eth0"
disk = ['file:/export/xen_test/centos.img,hda,w']
vif = ['']
on_shutdown = "destroy"
on_reboot = "destroy"
on_crash = "destroy"

4) Install solaris nevada PV domU with iso or CDROM by virt-install

Install from iso image
bash-3.2# /usr/bin/virt-install -p -n domu-x01 -r 1200 --nographics /
    -f /export/xen_test/snv76_pv.img -m "aa:ff:bb:ff:cc:cc" /
    -l /net/bounty/ftp/pub/CDimages/nv/76/x86/solarisdvd.iso

Install from CDROM
bash-3.2# /usr/bin/virt-install -p -n domu-x01 -r 1200 --nographics /
    -f /export/xen_test/snv76_pv.img -m "aa:ff:bb:ff:cc:cc" /
    -l /dev/dsk/c0t0d0s2

5) Jumpstart net install solaris nevada PV domU by virt-install
bash-3.2# /usr/bin/virt-install -d -p --nographics -n zealot /
    -f /export/xen_test/snv76_pv.img -r 1024 /
    --mac="aa:ff:bb:aa:27:17" -l "nfs:10.13.32.48:/export/nv/x/latest" /
    --autocf="nfs:129.158.218.84:/work/jumpstart_domU"

Note that in the command line above,  domU name following the option,
"-n", must be a valid hostname, which virt-install will resolve in order to
get the host-ip for installation.

6) Install solaris nevada HVM domU by virt-install
bash-3.2# /usr/bin/virt-install -v -n domu-x01 -r 1200 --vnc /
    -f /export/xen_test/snv76_pv.img -m "aa:ff:bb:ff:cc:cc" /
    --cdrom=/net/bounty/ftp/pub/CDimages/nv/76/x86/solarisdvd.iso

7) Install linux PV domU by virt-install
bash-3.2# /usr/bin/virt-install -n centos5 -p -r 1024 /
    -f /export/xen_test/centos.img -m aa:04:03:35:a8:4e /
    --nographics -l nfs:129.158.218.44:/mnt

8) Install windows HVM domU by virt-install
Firstly, enable the workaround of 6567064,
bash-3.2# svccfg -s xvm/xend setprop config/vncpasswd = astring: /"/"
bash-3.2# svcadm refresh xvm/xend
bash-3.2# svcadm restart xvm/xend

Then start the installation,
bash-3.2# /usr/bin/virt-install -v -n vista_domU -r 1024 /
    -f /export/xen_test/vista.img -m aa:04:03:35:a8:4e /
    --vnc --cdrom=/dev/dsk/c0t0d0s2 --os-type=windows

For vista domU, the option, --os-type=windows is essential.
With it ACPI will be enabled in the domU,  otherwise vista
installation program will complain that BIOS is not ACPI
compatible and refuse to go on.

9) Create a HVM domU by xm
Here's the template file:

=========================================================
# -*- mode: python; -*-
#----------------------------------------------------------------------------------------------------
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#----------------------------------------------------------------------------------------------------

import os, re
arch = os.uname()[4]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'

#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"

# The domain build function. HVM domain uses 'hvm'.
builder='hvm'

# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 512

# Shadow pagetable memory for the domain, in MB.
# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8

# A name for your domain. All domains must have different names.
name = "Windows-on-Solaris"

# 128-bit UUID for the domain. The default behavior is to generate a new UUID
# on each call to 'xm create'.
#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9"

#-----------------------------------------------------------------------------
# the number of cpus guest platform has, default=1
vcpus=1

# enable/disable HVM guest PAE, default=0 (disabled)
#pae=0

# enable/disable HVM guest ACPI, default=0 (disabled)
#acpi=1

# enable/disable HVM guest APIC, default=0 (disabled)
#apic=1

# List of which CPUS this domain is allowed to use, default Xen picks
#cpus = "" # leave to Xen to pick
#cpus = "0" # all vcpus run on CPU0
#cpus = "0-3,5,^1" # run on cpus 0,2,3,5

# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.

#vif = [ 'type=ioemu' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.

#disk = [ 'file:/export/home/mydisk.raw,hdc,w', 'file:/export/home/install.iso,hda:cdrom,r' ]

#disk = [ 'phy:/dev/dsk/c1d0p0,hdc,w', 'file:/export/home/install.iso,hda:cdrom,r' ]

#disk = [ 'phy:/dev/zvol/dsk/mypool/mydisk,hdc,w', 'file:/export/home/install.iso,hda:cdrom,r' ]

#----------------------------------------------------------------------------
# Configure the behaviour when a domain exits. There are three 'reasons'
# for a domain to stop: poweroff, reboot, and crash. For each of these you
# may specify:
#
# "destroy", meaning that the domain is cleaned up as normal;
# "restart", meaning that a new domain is started in place of the old
# one;
# "preserve", meaning that no clean-up is done until the domain is
# manually destroyed (using xm destroy, for example); or
# "rename-restart", meaning that the old domain is not cleaned up, but is
# renamed and a new domain started in its place.
#
# The default is
#
# on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# For backwards compatibility we also support the deprecated option restart
#
# restart = 'onreboot' means on_poweroff = 'destroy'
# on_reboot = 'restart'
# on_crash = 'destroy'
#
# restart = 'always' means on_poweroff = 'restart'
# on_reboot = 'restart'
# on_crash = 'restart'
#
# restart = 'never' means on_poweroff = 'destroy'
# on_reboot = 'destroy'
# on_crash = 'destroy'

on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'preserve'

# New stuff
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'

#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
#boot="cda"
boot='d'

#-----------------------------------------------------------------------------
# write to temporary files instead of disk image files
#snapshot=1

#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=1

#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=0

#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
vnclisten="0.0.0.0"

#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1

#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1

#----------------------------------------------------------------------------
# enable spawning vncviewer for domain's console
# (only valid when vnc=1), default = 0
vncconsole=1

vncpasswd=''

#----------------------------------------------------------------------------
# no graphics, use serial port
nographic=0

#----------------------------------------------------------------------------
# enable stdvga, default = 0 (use cirrus logic device model)
stdvga=0

#-----------------------------------------------------------------------------
# serial port re-direct to pty deivce, /dev/pts/n
# then xm console or minicom can connect
#serial='pty'
#serial='stdio'
#serial='file:/tmp/blah'
#serial='/dev/pts/0'
serial='null'


#-----------------------------------------------------------------------------
# enable sound card support, [sb16|es1370|all|..,..], default none
#soundhw='sb16'


#-----------------------------------------------------------------------------
# set the real time clock to local time [default=0 i.e. set to utc]
#localtime=1


#-----------------------------------------------------------------------------
# start in full screen
#full-screen=1


#-----------------------------------------------------------------------------
# Enable USB support (specific devices specified at runtime through the
# monitor window)
#usb=1

# Enable USB mouse support (only enable one of the following, `mouse' for
# PS/2 protocol relative mouse, `tablet' for
# absolute mouse)
#usbdevice='mouse'
#usbdevice='tablet'

=========================================================

We need to pay attention to several options in the HVM config above,
bash-3.2# more vista.py
...
# Initial memory allocation (in megabytes) for the new domain.
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
memory = 2048
# Shadow pagetable memory for the domain, in MB.
# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 48
# A name for your domain. All domains must have different names.
name = "WinVista"
vif = [ 'type=ioemu' ]
disk = [ 'file:/export/xen_test/vista.img,hdc,w', 'phy:/dev/dsk/c0t0d0s2,hda:cdrom,r' ]
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
#boot="cda"
boot='d'
#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0
#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=1
#-----------------------------------------------------------------------------
# Enable USB support (specific devices specified at runtime through the
# monitor window)
usb=1
# Enable USB mouse support (only enable one of the following, `mouse' for
# PS/2 protocol relative mouse, `tablet' for
# absolute mouse)
usbdevice='mouse'
usbdevice='tablet'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值