Virtualization

From Hack Sphere Labs Wiki
Jump to: navigation, search
  • HVM is hardware and faster
  • PV is Paravirtualization and usually slower

The networking scripts that come with xen are going to be phased out because they do not work all the time. You should setup bridge manually.

Management

Xen Dom0 Memory Limit

From: https://wiki.debian.org/Xen

Configure Domain 0 Memory

By default on a Xen system the majority of the hosts memory is assigned to dom0 on boot and dom0's size is dynamically modified ("ballooned") automatically in order to accomodate new guests which are started.

However on a system which is dedicated to running Xen guests it is better to instead give dom0 some static amount of RAM and to disable ballooning.

The following examples use 1024M.

In order to do this you must first add the dom0_mem option to your hypervisor command line. This is done by editing /etc/default/grub and adding

# Xen boot parameters for all Xen boots
GRUB_CMDLINE_XEN="dom0_mem=1024M"

at the bottom of the file.

Note : On servers with huge memory, Xen kernel crash. You must set a dom0 memory limit. Take care on Wheezy, 1024M is not enough and cause kernel crash at boot with out-of-memory message.

Remember to apply the change to the grub configuration by running update-grub!

Then edit /etc/xen/xend-config.sxp to configure the toolstack to match by changing the following settings:

(dom0-min-mem 1024)
(enable-dom0-ballooning no)

At this point you should reboot so that these changes take effect.

Xen Repair Corrupted Filesystem Images

  • Do this:
fsck.ext4 -y -f /home/vm/vm01.img

or

fsck.ext3 -y -f /home/vm/vm01.img

or

fsck.ext2 -y -f /home/vm/vm01.img

or

xfs_check -f /home/vm/vm01.img

... the case for your filesystem type.

Xen Shutdown CIFS

Normal shutdown kills networking and CIFS before the domU's shutdown.

Shutdown your domU's as part of your drop to runlevel 0.

or just

xm shutdown --all


Xen Mount Loop Image

Links Below

Notes

Xen Grow Disk

Debian Xen

Persist Across Reboots

Debian has scripts in place:

/etc/default/xendomains
/etc/init.d/xendomains 


Install

apt-get install xen-linux-system
apt-get install xen-qemu-dm-4.0
dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xen
update-grub

May want to do this eventually to limit dom0 ram:

/etc/default/grub
# Xen boot parameters for all Xen boots
GRUB_CMDLINE_XEN="dom0_mem=1024M"

then

update-grub

then edit

/etc/xen/xend-config.sxp
(dom0-min-mem 1024)
(enable-dom0-ballooning no)

You would then need to reboot.

Install python-xml

Debian removed python-xml because it has not been updated.

You need it for the command xm new so:

wget http://sourceforge.net/projects/pyxml/files/latest/download

(You may have to go to that site and get a direct link)

cp -r PyXML-0.8.4/xml/parsers/xmlproc/ \
   /usr/lib/python2.5/xml/parsers/
cp -r PyXML-0.8.4/xml/utils /usr/lib/python2.5/xml/

Notes

Network Scripts

They do not want you to use these anymore and instead setup the bridging up manually. You want to comment out anything with

(network-script

in front of it and do it right.

I did not even use the vif-script

/etc/xen/scripts/network-bridge
/etc/xen/scripts/vif-bridge

Notes

Configure Networking and Install

Debian wiki states that the network control scripts that come with Xen are going to be phased out eventually. Goes on to say that you should setup networking yourself.

Note: You need to zero out your eth0 connection or the bridge will stop communication to eth0.

Something like:

ifconfig eth0 0.0.0.0

You cannot have and address assigned to eth0 and have it bridged at the same time. It will not work. I do not know if an alias would work. Like eth0:0 or whatever.

aptitude install bridge-utils
brctl addbr br0
  • br0 could be anything like: whatever0
ip addr show
  • Just to see interfaces

You now need to add interfaces to the bridge

brctl addif br0 eth0 eth1

To make the bridge perm you need to edit /etc/network/interfaces

 /etc/network/interfaces 

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
iface eth0 inet manual
#allow-hotplug eth0
#iface eth0 inet static
#	address 192.168.0.10
#	netmask 255.255.255.0
#	network 192.168.0.0
#	broadcast 192.168.0.255
#	gateway 192.168.0.1
#	# dns-* options are implemented by the resolvconf package, if installed
#	dns-nameservers 192.168.0.1

auto xenbr0
iface xenbr0 inet dhcp
	bridge_ports eth0

auto br0
iface br0 inet static
       bridge_ports eth0
       address 192.168.0.10
       netmask 255.255.255.0
       network 192.168.0.0
       broadcast 192.168.0.255
       gateway 192.168.0.1
       # dns-* options are implemented by the resolvconf package, if installed
       dns-nameservers 192.168.0.1


or something using ethernet aliases:

 /etc/network/interfaces 
 

# NETWORK BRIDGE EXAMPLE FOR A DEBIAN SYSTEM WITH A SINGLE NIC

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

# Network bridge
auto br0
iface br0 inet static
address 11.22.33.2
network 11.22.33.0
netmask 255.255.255.192
broadcast 11.22.33.63
gateway 11.22.33.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

# Internal networking
auto br0:0
iface br0:0 inet static
address 10.0.1.2
netmask 255.255.255.0


You then could edit /etc/xen/xend-config.sxp but since the networking scripts included with xen may be phased out at any moment you should just configure the domu's to use the bridge. xen-tools will do this if you configure it to. You will need a vif line in the domU config to use the bridge:

vif = ['mac=00:00:00:00:00:00,bridge=xenbr0]
 /etc/xen-tools/xen-tools.conf 
 
bridge = xenbr0

Notes

bridge_stp off		# disable Spanning Tree Protocol
bridge_waitport 0	# no delay before a port becomes available
bridge_fd 0		# no forwarding delay

Install DomU xen-tools

To configure xen-tools, you can edit /etc/xen-tools/xen-tools.conf which contains default values that the xen-create-image script will use. The xen-create-image(8) manual page contains information on the available options.

xen-create-image --hostname <hostname> --ip <ip> --vcpus 2 --pygrub --dist <lenny|squeeze|maverick|whatever>

Install DomU Debian Installer

uuid

VPS Serving to Customers

http://vimeo.com/38636349

Notes

HyperVM Free and looks like a great product. Does not work with CentOS 6 because CentOS dropped Xen?
  • Xen XCP
  • OpenVZ
  • Virtuzzo
  • ProxMox
  • SolusVM
  • vePortal


Most of these can integrate with a billing platform.

  • lxcenter.org

kloxo


DomU Install Lines and/or Config Files

Debian

xen-create-image --hostname ahostname --vcpus 1 --pygrub --dist squeeze

Windows 7

dd if=/dev/zero of=xenwin7.img bs=1024k seek=10000 count=0

win7.cfg

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

kernel = "hvmloader"
builder='hvm'
memory = 1024

# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8
name = "xenwin7"
vif = [ 'type=ioemu, bridge=xenbr0' ]
acpi = 1
apic = 1
disk = [ 'file:/home/xen/xenwin7.img,hda,w', 'file:/home/xen/windows7.iso,hdc:cdrom,r' ]

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="dc"
sdl=0
vnc=1
vncconsole=1
vncpasswd='bla'

serial='pty'
usbdevice='tablet'

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'


Notes

Android x86

Tested with: http://android-x86.googlecode.com/files/android-x86-4.0-RC2-eeepc.iso

It works fine but ethernet is not supported in ICS. I do not need it right now.

Create disk image:

dd if=/dev/zero of=disk.img bs=1024k seek=10000 count=0
android.x86.cfg
import os, re
arch = os.uname()[4]
if re.search('64', arch):
    arch_libdir = 'lib64'
else:
    arch_libdir = 'lib'

kernel = "hvmloader"
builder='hvm'
memory = 256

# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8
name = "android-x86"
vif = [ 'type=ioemu, bridge=xenbr0, mac=00:13:3A:51:2B:1E' ]
acpi = 1
apic = 1
#uncomment this to boot the cd
#disk = [ 'file:/media/pulsar0/vm/domains/android.x86/disk.img,hda,w', 'file:/media/pulsar0/iso/android-x86-4.0-RC2-eeepc.iso,hdc:cdrom,r' ]
disk = [ 'file:/media/pulsar0/vm/domains/android.x86/disk.img,hda,w' ]

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="dc"
sdl=0
vnc=1
vncconsole=1
vncpasswd='PUTYOURPASSWORDHERE'
vnclisten=''
vncdisplay='30'

serial='pty'
usbdevice='tablet'

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'