1999 The Central Ohio Linux User Group. // All rights reserved. // Released under the GPL, v. 2. See: LICENSE.TXT // This file: template/header.php // // // echo "\n"; print ""; echo "\n"; echo ""; echo ""; echo "Rossberry.com - The Home of the Mobile Linux Lab"; if ($title != "") { echo " -- $title"; } echo "\n"; // The next line lets us link the header page below // the top ditrectory, and have the buttons work // RPH -- 011124 echo ""; // // scheme://user:pass@host:port/path?query#fragment // //$REQUEST_URI = $_SERVER[REQUEST_URI]; $url=parse_url("$REQUEST_URI"); $svr=$url[host]; //$svr="www.rossberry.net"; $svr="www.rossberry.com"; $server = $server_name ; print ""; ?>

Rossberry.com

Home of the Mobile Linux Lab

Home Overview Philosophy Infrastructure
Version Control Blogs Files cfengine

Xen setup and tweaks

If it is not already installed, then
yum install xen virt-manager kernel-xen xen-libs libvirt-python
virt-viewer virt-manager libvirt python-virtinst

If you just installed Xen, then you will probably need to reset the default grub boot entry and reboot into the Xen enabled kernel. If you have the memory for it, I've found that my laptop works best if I lock dom0 into 1G of RAM. If I let it balloon up and down I get memory squeeze errors. If I go below 1G, my dom0 performance (like for editing) suffers. To do this...

  • In /boot/grub/grub.conf I add "dom0_mem=1024M" to the "kernel" line for my Xen image
  • In /etc/xen/xend-config.sxp add "(dom0-min-mem 1024)

Once we are running our Xen enabled kernel, we need to create our first domU (guest). This vm will be known as buildhost and will host the build server, dhcp and DNS services for the virtual networks.

Design note: I've played with hosting all the services on dom0. While this is one way to do it, I prefer hosting them on a domu.

  • I don't have to run them unless I need them. Sometimes I use my laptop as just a laptop (shock shock). I really don't want dhcp, dns, nfs, web server and all that running on a desktop. It kills the battery life if nothing else
  • Running the services on a domU makes it easy to move the whole pile to another dom0 machine if I want to. And to make a backup
  • The combination of the first two makes it simpler to rebuild my host laptop if I want or need to. Just rsync the domU's to other storage and off I go.

NB: Do this after you create the buildhost vm
We need to setup a host only network. The easiest way that I know of is to use the graphical virt-manager tool.

  • Select the host and right click.
  • Select "Details"
  • Select the "Virtual Network" tab
  • Click on the green "+" in the lower left corner
  • Type in a name (hostonly comes to mind)
  • Follow the "Forward" buttons leaving the defaults and choosing "Isolated virtual network" on the "Connecting to physical network" screen. Choose finish to save your work.
  • cd /var/lib/libvirt/network
  • vi .xml
    delete the following 3 lines
        <dhcp>
             <range start='192.168.0.128' end='192.168.0.254' />
        </dhcp>
    
  • save the file and reboot the machine.

Much as I've tried I have not found a way to definitely get back to the startup state w/o rebooting. There always seems to be a piece that is not quite the same.

{I repeat this for all the networks, which prevents dnsmasq from starting. I prefer to use the full blown dhcp server (as detailed elsewhere) since it is unlikely that dnsmasq will be used in the enterprise. By running dhcpd I also have full control over it rather than the "auto magical" incarnation of dnsmasq by libvirtd.} Here are my network config files. As noted I've removed the dhcp stanzas. I also used picked the 3rd octets to be easy to work with.

default.xml (virbr0)

<network>
  <name>default<name>
  <uuid>df1f2949-0f98-4091-a2f9-2054c81402d2<uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' forwardDelay='0' />
  <ip address='192.168.100.1' netmask='255.255.255.0'>
  <ip>
<network>

hostonly.xml (virbr1)

<network>
  <name>hostonly<name>
  <uuid>43fee0b0-ad42-2597-7624-d2101ed70bf6<uuid>
  <bridge name='virbr1' stp='on' forwardDelay='0' />
  <ip address='192.168.200.1' netmask='255.255.255.0'>
  <ip>
<network>

As noted in the overview, we will use both disk image (file) based vm's and logical volume based vm's. In particular the build server (buildhost) and the cfengine master are image based. Other vm's will be lvm based so I can clone them.

Some comments on the clone_vm.sh script.

  • The initial vm in each group needs to be named vmX (vm1, vm2, vm3) and should be installed on a logical volume named lv_vmX (lv_vm1, lv_vm2, etc).
  • It should use the hostonly interface.
  • Each vm should be a representative, minimal build that is suited for replication.
  • The vm's need to have the HARDWARE lines removed from /etc/sysconfig/network-scripts/ifcfg-eth0, and the HOSTNAME line removed from /etc/sysconfig/network. This is done automatically by the %post section of my base kickstart file
  • The kickstart process also prepopulates some ssh keys and sets up an nfs mount of /home/jawildman.
  • Once built, turn the vmX off until you need to rebuild it.
  • The script takes 2 parameters; the ordinal of the vm(1,2,3,4) and the ordinal of the snapshot to create. I usually call it in a for loop.
  • It will xm destroy any currently running vm's, removes any current snapshots and creates new ones.
  • It sets the mac address based on the 2 ordinals given, which are then reflected in the dhcpd.conf file.
  • Based on my current needs, it is limited to 4 snapshots.
  • Things to edit
    • the volume group name (currently vg_tosh)
    • possible the virbr number, UUID base and mac base, depending on your setup.
  • WHY? Because most vm's are built from a common base. I usually rebuild a vm to get it back to a known state so I can try specific things on it. Even on my laptop with it's 7200 RPM drive, I can create a clone in less than 15 seconds. Hard to kickstart them that fast. Since I'm going to destroy them anyway, copying an entire image (even a small < 1G one) would be a waste and take much longer.

1999 The Central Ohio Linux User Group. // All rights reserved. // Released under the GPL, v. 2. See: LICENSE.TXT // This file: template/footer.php // print "


"; // print " \n \n \n "; // $url=parse_url("$REQUEST_URI"); $scheme = $url[scheme]; $host = $url[host]; $whereami = $url[path]; $basename = exec("basename $whereami"); $REFERRER=exec("basename $whereami .php"); $SMURF = exec(" ls | grep $REFERRER | grep txt "); if ($SMURF != "") { ## echo ""; ## This next line of code opens the displayed code in a new window when uncommented echo ""; echo "\"View of "; echo ""; echo "$basename"; } else { print "\n"; print "\n"; } // print " Contact mll@rossberry.com Copyright\n © 2010, 2011 Jim Wildman.\n "; print "
All rights reserved.
"; ?>