[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 02/13] ts-freebsd-install: add FreeBSD PVHVM installer



From: Roger Pau Monne <roger.pau@xxxxxxxxxx>

Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx>
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 ts-freebsd-install |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 ts-freebsd-install

diff --git a/ts-freebsd-install b/ts-freebsd-install
new file mode 100644
index 0000000..4e32b6c
--- /dev/null
+++ b/ts-freebsd-install
@@ -0,0 +1,109 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our ($whhost,$gn) = @ARGV;
+$whhost ||= 'host';
+$gn ||= 'freebsd';
+
+our $ho= selecthost($whhost);
+
+our $ram_mb=   1024;
+our $disk_mb= 20480;
+
+our $guesthost= "$gn.guest.osstest";
+our $gho;
+
+our $xl= toolstack()->{Command};
+
+our $freebsd_qcow2= '/root/freebsd.qcow2';
+our $freebsd_raw= '/root/freebsd.raw';
+
+our $freebsd_mount= '/root/freebsd_root';
+
+our $freebsd_version= "10.0-BETA3";
+
+# Folder where the FreeBSD VM images are stored inside of the host
+#
+# The naming convention of the stored images is:
+# FreeBSD-$freebsd_version-$arch.qcow2.xz
+# ie: FreeBSD-10.0-BETA3-amd64.qcow2.xz
+our $freebsd_vm_repo= '/var/images';
+
+sub prep () {
+    my $authkeys= authorized_keys();
+
+    target_install_packages_norec($ho, qw(lvm2 wget qemu-utils xz-utils 
kpartx));
+
+    $gho= prepareguest($ho, $gn, $guesthost, 22,
+                       $disk_mb + 1,
+                       100);
+
+    more_prepareguest_hvm($ho, $gho, $ram_mb, $disk_mb, NoCdromImage => 1);
+
+    my $freebsd_img = $freebsd_vm_repo . "/" . "FreeBSD-" . $freebsd_version . 
"-";
+    # Use amd64 as default arch
+    $freebsd_img .= defined($r{"$gho->{Guest}_arch"}) ? 
$r{"$gho->{Guest}_arch"} : 'amd64';
+    $freebsd_img .= ".qcow2.xz";
+
+    target_cmd_root($ho, "umount $gho->{Lvdev} ||:");
+
+    target_cmd_root($ho, <<END, 900);
+            xz -dkc $freebsd_img > $freebsd_qcow2
+            qemu-img convert -f qcow2 $freebsd_qcow2 -O raw $freebsd_raw
+            rm -rf $freebsd_qcow2
+            dd if=$freebsd_raw of=$gho->{Lvdev} bs=1M
+            rm -rf $freebsd_raw
+
+            kpartx -a $gho->{Lvdev}
+            mkdir -p $freebsd_mount
+            mount -t ufs -o ufstype=ufs2,rw 
/dev/mapper/$gho->{Vg}-$gho->{Name}--disk3 $freebsd_mount
+
+            mkdir -p $freebsd_mount/root/.ssh
+            cat <<'ENDKEYS' >$freebsd_mount/root/.ssh/authorized_keys
+$authkeys
+ENDKEYS
+
+            echo 'sshd_enable="YES"' >> $freebsd_mount/etc/rc.conf
+            echo 'ifconfig_xn0="DHCP"' >> $freebsd_mount/etc/rc.conf
+            echo 'PermitRootLogin yes' >> $freebsd_mount/etc/ssh/sshd_config
+
+            sed -i '/^ttyu0/s/off/on/' $freebsd_mount/etc/ttys
+
+            cp $freebsd_mount/usr/share/zoneinfo/Europe/London 
$freebsd_mount/etc/localtime
+
+            cat <<'ENDKEYS' >$freebsd_mount/boot/loader.conf
+boot_multicons="YES"
+boot_serial="YES"
+comconsole_speed="115200"
+console="comconsole,vidconsole"
+ENDKEYS
+
+            umount $freebsd_mount
+            rm -rf $freebsd_mount
+            kpartx -d $gho->{Lvdev}
+END
+
+}
+
+prep();
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.