unattended installs
Ok, I am sending out the first pass at the unattended install scripts. I have tested with both Linux and Windows guests and everything seems ok. I have been hitting a couple issues and I am sure there are more that need to be resolved however I wanted some initial feedback...
Requires the processor patch as well as the patch to "strip and split" to allow extra =.
Windows guests will automatically pick up a .sif file on the "floppy disk" while linux guest require pxe to pass in the kernel parameter "ks=floppy" to force an unattended install. This also allows for pxe to pass in additional kernel parameters specified in the config file.
I had some issues getting the guest to read a vvfat floppy passed to the guest via qemu option "-fda fat:floppy:rw:./floppy" it would pass the dir as a vfat disk and the guest could mount it, however guest could not read the files on the vdisk......
PATCH 1/1 added script for unattended install
--- client/tests/kvm_runtest_2/scripts/unattended.sh | 220 ++++++++++++++++++++++ 1 files changed, 220 insertions(+), 0 deletions(-) create mode 100755 client/tests/kvm_runtest_2/scripts/unattended.sh
client/tests/kvm_runtest_2/scripts/unattended.sh new file +220 -0
@@ -0,0 +1,220 @@ +#!/bin/bash +# +# unattended.sh - sets up environment for an unattended install for kvm_autotest +# +# Copyright (C) 2009 Red Hat, Inc. +# Written by: +# David Huff <[email protected]> +# Darryl L. Pierce <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. A copy of the GNU General Public License is +# also available at http://www.gnu.org/copyleft/gpl.html. + + +ME=$(basename "$0") +warn() { printf '%s: %s\n' "$ME" "$*" >&2; } +die() { warn "$*"; exit 1; } +debug() { if $debugging; then log "[DEBUG] %s" "$*"; fi } + +set -e + +log () { + date=$(date) + printf "${date} $*\n" +} + +usage () { + cat <<EOF +Usage: $ME [-c unattended_config_file] [-n name] [LOGFILE] + -a: auto, pulls parameters from environment + -c: unattended config file to use + -n: name to append to floppy.img + -p: pxeboot and use iso image provided to setup pxe tree + -k: extra kernel args to use when pxe booting + -d: enable more verbose output (default: disabled) + -v: enable tracing (default: disabled) + -h: display this help and exit +EOF +} + +# creates a folder to use as virtual floppy disk +# copys correct config file to this dir +create_virtual_floppy_disk () { + local dir="floppy" + + if [ -d $dir ]; then + rmdir $dir + fi + + mkdir $dir + + #copy config file to disk + if [[ "$CONFIG" =~ \.ks\$ ]] || [["$CONFIG" =~ \.cfg\$ ]]; then + cp $CONFIG $dir/ks.cfg + else + cp $CONFIG $dir + fi + + #change permissions + #chmod 755 $filename +} + + +# creates a floppy disk file and adds unattended config file +# $CONFIG file to stick on floppy disk +create_floppy_disk () { + local size="144" + local filename="images/floppy.img" + + #create floppy disk image + debug "Creating floppy disk: filename=${filename} size=${size}" + qemu-img create -f raw $filename "${size}M" > /dev/null 2>&1 + mkfs.msdos $filename + + #mount floppy disk image + mp=$(mktemp -d floppytmp.XXXXXX) + mount -t vfat -v -o loop $filename $mp + + #copy config file to disk + if [[ "$CONFIG" =~ \.ks\$ ]] || [["$CONFIG" =~ \.cfg\$ ]]; then + cp $CONFIG $mp/ks.cfg + else + cp $CONFIG $mp + fi + + #unmount floppy + df | grep $mp > /dev/null 2>&1 && umount -v $mp + rmdir $mp + + #change permissions + chmod 755 $filename +} + + +# setup pxeboot evironment +# $PXE - iso image +# $ARGS - kernel arguments +setup_pxeboot () { + local workdir=$PWD/tftpboot + local iso=$PXE + local pxedefault=$workdir/pxelinux.cfg/default + local pxelinux="/usr/lib/syslinux/pxelinux.0" + local cdlocation="images/pxeboot/" + + # Check pxelinux.0 exists. + if [ ! -f /usr/share/syslinux/pxelinux.0 -a ! -f /usr/lib/syslinux/pxelinux.0 ]; then + die "Warning: pxelinux.0 not found, Make sure syslinux or pxelinux is installed on this system." + fi + + #create clean tftpboot dir + if [ -d $workdir ]; then + log "$ME: subdirectory $workdir exists already. overwriting" + rm -rf $workdir + fi + + mkdir -p $workdir/pxelinux.cfg + + # pxelinux bootloader. + if [ -f /usr/share/syslinux/pxelinux.0 ]; then + cp /usr/share/syslinux/pxelinux.0 $workdir + elif [ -f /usr/lib/syslinux/pxelinux.0 ]; then + cp /usr/lib/syslinux/pxelinux.0 $workdir + else + die "Warning: pxelinux.0 not found, Make sure syslinux or pxelinux is installed on this system." + fi + + # get vmlinz and initrd form image + mp=$(mktemp -d cdtmp.XXXXXX) + mount -v -o loop "$iso" $mp + + # Does it look like an ISO? + if [ ! -d $mp/$cdlocation ]; then + die "The ISO image doesn't look like a ISO image to me." + fi + + cp $mp/$cdlocation/initrd.img $mp/$cdlocation/vmlinuz $workdir + df | grep $mp > /dev/null 2>&1 && umount -v $mp + rmdir $mp + + # set default kernel arguments if none were provided + if [ -z "$ARGS" ]; then + local $ARGS="" + fi + + local definition="DEFAULT pxeboot" + definition="${definition}\nTIMEOUT 20" + definition="${definition}\nPROMPT 0" + definition="${definition}\nLABEL pxeboot" + definition="${definition}\n KERNEL vmlinuz" + definition="${definition}\n IPAPPEND 2" + definition="${definition}\n APPEND initrd=initrd.img $ARGS" + + debug "pxeboot definition=\n${definition}" + printf "${definition}\n" > $pxedefault +} + +debugging=false +CONFIG= +NAME= +PXE= +ARGS= + +while getopts adc:n:p:k:vh c; do + case $c in + a) CONFIG=$KVM_TEST_unattended_file + NAME=$KVM_TEST_image + PXE=isos/$KVM_TEST_cdrom + ARGS=$KVM_TEST_kernel_args;; + d) debugging=true;; + c) CONFIG=$OPTARG;; + n) NAME=$OPTARG;; + p) PXE=$OPTARG;; + k) ARGS=$OPTARG;; + v) set -v;; + h) usage; exit 0;; + '?') die "invalid option \`-$OPTARG'";; + :) die "missing argument to \`-$OPTARG' option";; + *) die "internal error";; + esac +done + +shift $(($OPTIND - 1)) + +set +u +if [ $# -gt 0 -a -n "$1" ]; then RESULTS=$1; else RESULTS=unattended.log; fi +set -u + +# check to see we are root +if [ $( id -u ) -ne 0 ]; then + die "Must run as root" +fi + +log "$ME: Logging results to file: ${RESULTS}" + +# Require "-o OUTPUT_FILE" +if test -z $CONFIG; then + die "no config file for unattended install" +fi + +log "$ME: using unattended config file: $CONFIG" + +# create teh floppy image +create_floppy_disk $CONFIG +#create_virtual_floppy_disk $CONFIG + +#if [ $PXE ]; then + debug "$ME: using $PXE to set up pxe environmet" + setup_pxeboot +#fi
Signature · 1 line
1.6.0.6
PATCH 1/1 modified sample config file to include one example of unattended install
In reply to David Huff--- client/tests/kvm_runtest_2/kvm_tests.cfg.sample | 28 +++++++++++++++++++++- 1 files changed, 26 insertions(+), 2 deletions(-)
client/tests/kvm_runtest_2/kvm_tests.cfg.sample +26 -2
@@ -39,6 +39,16 @@ variants: type = steps fail_if_stuck_for = 300 stuck_detection_history = 2 + + - unattended_install: + type = boot + kill_vm_on_error = yes + pre_command = scripts/unattended.sh -a + extra_params = "-fda images/floppy.img -boot d" + variants: + - pxe: + extra_params = "-fda images/floppy.img -bootp /pxelinux.0 -tftp ./tftpboot/ -boot n" + kernel_args = "ks=floppy" - boot: install setup type = boot
@@ -116,7 +126,12 @@ variants: cdrom = linux/Fedora-8-i386-DVD.iso md5sum = dd6c79fddfff36d409d02242e7b10189 md5sum_1m = dabae451bb69fbbad0e505b25144b1f9 - + unattended_install: + unattended_file = unattended_files/Fedora-8-i386.ks + cdrom = linux/Fedora-8-i386-DVD.iso + md5sum = dd6c79fddfff36d409d02242e7b10189 + md5sum_1m = dabae451bb69fbbad0e505b25144b1f9 + - 8.64: no setup image_name = fc8-64
@@ -554,6 +569,15 @@ variants: - @custom: only qcow2.*ide.*default.*up.*Ubuntu-8.10-server.*(autotest.sleeptest) only rtl8139 + - @fc8_kickstart: + only qcow2 + only ide + only default + only up + only Fedora.8.32 + no install setup + only unattended_install.pxe + only rtl8139 # Choose your test list -only fc8_quick +only fc8_kickstart
Signature · 1 line
1.6.0.6
Quoted 7 lines · David Huff
Ok, I am sending out the first pass at the unattended install scripts. I have tested with both Linux and Windows guests and everything seems ok. I have been hitting a couple issues and I am sure there are more that need to be resolved however I wanted some initial feedback...
Requires the processor patch as well as the patch to "strip and split" to allow extra =.
typo: patches require:
[PATCH] [KVM_Autotest] Added functionality to the preprocessor to run scripts
[PATCH] [KVM_Autotest] Fix to allow for "=" in the "value" of a config parameter
Quoted 14 lines
Windows guests will automatically pick up a .sif file on the "floppy disk" while linux guest require pxe to pass in the kernel parameter "ks=floppy" to force an unattended install. This also allows for pxe to pass in additional kernel parameters specified in the config file.
I had some issues getting the guest to read a vvfat floppy passed to the guest via qemu option "-fda fat:floppy:rw:./floppy" it would pass the dir as a vfat disk and the guest could mount it, however guest could not read the files on the vdisk......
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · David Huff
I had some issues getting the guest to read a vvfat floppy passed to the guest via qemu option "-fda fat:floppy:rw:./floppy" it would pass the dir as a vfat disk and the guest could mount it, however guest could not read the files on the vdisk......
I'm surprised you opted to work around this with a loop mount rather than using mtools, given the former approach's need for root.
Granted, getting files off the ISO _could_ also require root -- in my own analog to these scripts, I use iso-read (from the libcdio package):
# Pull kernel and initrd
iso-read --image "$OS_ISO" \
--extract /isolinux/vmlinuz \
--output-file "$TMPDIR/vmlinuz"
iso-read --image "$OS_ISO" \
--extract /isolinux/initrd.img \
--output-file "$TMPDIR/initrd.img"# Write floppy image
mformat -C -f 1440 -i "$TMPDIR"/floppy.img ::
mcopy "$TMPDIR"/floppy.d/* -i "$TMPDIR"/floppy.img ::/
Quoted 8 lines · Charles Duffy
Quoted 4 lines · David Huff
I had some issues getting the guest to read a vvfat floppy passed to the guest via qemu option "-fda fat:floppy:rw:./floppy" it would pass the dir as a vfat disk and the guest could mount it, however guest could not read the files on the vdisk......
I'm surprised you opted to work around this with a loop mount rather than using mtools, given the former approach's need for root.
Autotest runs the tests as root, so we will have root privileges anyway...
Quoted 18 lines
Granted, getting files off the ISO _could_ also require root -- in my own analog to these scripts, I use iso-read (from the libcdio package):
# Pull kernel and initrd
iso-read --image "$OS_ISO" \ --extract /isolinux/vmlinuz \ --output-file "$TMPDIR/vmlinuz" iso-read --image "$OS_ISO" \ --extract /isolinux/initrd.img \ --output-file "$TMPDIR/initrd.img"# Write floppy image
mformat -C -f 1440 -i "$TMPDIR"/floppy.img ::
mcopy "$TMPDIR"/floppy.d/* -i "$TMPDIR"/floppy.img ::/--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Lucas Meneghel Rodrigues Software Engineer (QE) Red Hat - Emerging Technologies