Solaris Xen Drop 66 – Setup Solaris HVM DomU

Once you have dom0 up and running properly, you'll need a virtual disk and an HVM config file to get an HVM domU running.

There are some caveats when running Solaris in an HVM domU: Solaris as an HVM Guest.

WARNING - Windows HVM domains are susceptible to viruses and worms - make sure you comply with all security policies, keep the firewall enabled, install virus software, and do all that is necessary to keep your network secure.

Creating a Virtual Disk for your domain

There are three verified ways to give your HVM domain a disk: lofi-backed files, physical disk partitions, and ZFS zvols.

lofi(7D) -backed file

The easiest and [currently] best-performing way to get a disk for your domain is to use a qemu RAW image file. To create one, you'll need the qemu-img utility. You can download it from this download area, or you can download qemu from blastwave, which will put qemu-img in /opt/csw/bin.

To create your disk, run it like this:

qemu-img create -f raw mydisk.raw 10G

This will create a 10-gig qemu disk image, which only takes up as much actual disk space as is needed to hold the data which has been written to it.

Notes:

  1. Surf to http://www.blastwave.org/packages.php. And get the qemu item from the list.

  2. Refer to this article, to get familiar with blastware and how to install packages from this site.

  3. To install the qemu, do the following simple commands:
    # pkg-get -i qemu
    # export PATH=$PATH:/opt/csw/bin

Physical disk partition

If you have a free partition on your physical disk, you can use it for your HVM domain directly as /dev/dsk/cndnpn.

ZFS zvol

To create a zvol, you must first have a ZFS pool set up.

zfs create -V 10G mypool/mydisk

This creates a 10-gig virtual disk, accessed via /dev/zvol/dsk/mypool/mydisk.

Creating a configuration for your HVM domain

Download this example configuration file, and modify the following items. Most of these parameters are identical to those used for PV domains. The example is also at the end of this document.

  • Set the amount of memory allocated to your domain:

memory = 512

  • Give your domain a name:

name = "Windows-on-Solaris"

  • Give your domain a virtual network interface by uncommenting the vif line (optional):

# Optionally define mac and/or bridge for the network interfaces. 
# Random MACs are assigned if not given.
vif = [ 'type=ioemu' ]

If you need to specify a specific mac address, it would look like this:

vif = [ 'type=ioemu,mac=00:bb:cc:dd:ee:ff' ]

(Be careful not to get too random with the mac address - particularly, if the least significant bit of the first hex pair is set, it becomes a multicast ethernet address, which is almost certainly not what you want.)

  • Assign virtual disks to your domain.

For block devices, use the phy: prefix; for files, use the file: prefix, which will cause them to be automatically lofi-mounted. Each disk must have a unique hdx identifier, where 'x' is the drive letter (starting with a, b, c, etc.). The :cdrom tag after the drive intentifier means that the disk will be presented as a CD or DVD drive.

For example, if you have created a qemu image at /export/home/mydisk.raw and the installer .iso for the OS you are trying to run is at /export/home/install.iso, your disk line should look like this:

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

You can, of course, use the physical CD drive on your dom0 machine, for example:

disk = [ 'file:/export/home/mydisk.raw,hdc,w', 'phy:/dev/dsk/c2t0p0,hda:cdrom,r' ]

  • Set the boot device:

boot='d'

This option instructs the virtual BIOS to boot off of the CDROM ('d'). To boot off the drive, use 'c'.

  • Choose a graphical console. VNC and libSDL are your choices.

libSDL uses X11 to display a window containing the virtual machine's graphics console on your local X desktop. You must make sure that remote X11 display to your desktop is functioning (that DISPLAY is correctly set, that xhost permits the remote host, and that the X server is configured to accept remote connections). Test this by remotely displaying an xterm to your desktop.

VNC has the usual advantage of allowing a client to disconnect and reconnect at will without destroying the session. If you close a libSDL console window, you cannot get it back and you'll have to restart your domain (and the domain might not continue to run).

To use libSDL, set the option in the config file:

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

To use VNC, do the opposite, and set the appropriate VNC options:

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

Use this command to obtain a VNC viewer:

java -jar /usr/share/gnome/vino/vino-client.jar VNC_address

where VNC_address is hostname:display

libSDL is on your machine already.

Fire it up

Make sure X11 display is working from dom0 to your desktop, and use xm to create an instance of your domain:

xm create config-example.hvm

The console window should pop up (unless you are using VNC and have turned off the vncconsole option), and xm list should show your domain consuming CPU time. If your domain stays at 0.0 CPU usage, something has gone wrong. Check the most recently timestamped logs in /var/log/xen (ls -lt will sort by modification date) to determine the source of the problem. The qemu-dm log file will indicate if there was a problem with the X11 display or a needed support library couldn't be found. Fix the problem (or ask for help), xm destroy your domain, and re-create it.

If you are using libSDL, click in the console window to interact with it (it will "grab" your keyboard and mouse), and press control-alt to exit the grab. This method ignores your xmodmap settings (dvorak users, watch out).

If you are using VNC, and notice a mismatch between the VNC mouse cursor and the cursor presented by the guest OS, you can use the workaround described in Xen bug #585: either disable mouse acceleration in the guest, or add the following to your config file:

usb=1 usbdevice='tablet'

Provided, of course, that the guest OS supports USB pointer devices.

Once you have a working config, you can use xm new to save it, and later xm start to instantiate it without needing the config file.

If you are using VNC, the VNC display number always seems to be 0, despite the setting of vncdisplay in the config file. This needs to be investigated.

Don't use the -c argument to xm create; serial ports for HVM domains are not yet supported under Solaris, and this will cause your domain to fail to boot.

Note:
1. After installation, change
boot='d'
to
boot ='c'
Boot the HVM OS from the virtual hard disk.


HVM Configuration Sample

Here's the configuration sample file:

#============================================================================
# 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 = "Sol66-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:/etc/xen/solaris.raw,hdc,w', 'file:/fs1/sol-nv-b66-x86-dvd.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'


你可能感兴趣的:(Solaris Xen Drop 66 – Setup Solaris HVM DomU)