summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap/lenny/bootstrap.sh23
-rw-r--r--kvm-wrapper.conf20
-rwxr-xr-xkvm-wrapper.sh5
3 files changed, 30 insertions, 18 deletions
diff --git a/bootstrap/lenny/bootstrap.sh b/bootstrap/lenny/bootstrap.sh
index b25a267..335a430 100755
--- a/bootstrap/lenny/bootstrap.sh
+++ b/bootstrap/lenny/bootstrap.sh
@@ -4,17 +4,21 @@
# -- bencoh, 2010/07/11
# -- asmadeus, 2010/07
-### Configuration
-BOOTSTRAP_REPOSITORY="http://ftp.fr.debian.org/debian/"
-BOOTSTRAP_FLAVOR="lenny"
if [[ "`uname -m`" == "x86_64" ]]; then
- BOOTSTRAP_LINUX_IMAGE="linux-image-amd64"
+ ARCH_SUFFIX="amd64"
else
- BOOTSTRAP_LINUX_IMAGE="linux-image-686"
+ ARCH_SUFFIX="686"
fi
+
+### Configuration
+BOOTSTRAP_LINUX_IMAGE="linux-image-$ARCH_SUFFIX"
+BOOTSTRAP_REPOSITORY="http://ftp.fr.debian.org/debian/"
+BOOTSTRAP_FLAVOR="lenny"
BOOTSTRAP_EXTRA_PKGSS="vim-nox,htop,screen,less,bzip2,bash-completion,locate,acpid,$BOOTSTRAP_LINUX_IMAGE"
-BOOTSTRAP_PARTITION_TYPE="msdos"
+BOOTSTRAP_PARTITION_TYPE="msdos" #FIXME should be able to define it per-vm
BOOTSTRAP_CONF_DIR="$BOOTSTRAP_DIR/$BOOTSTRAP_DISTRIB/conf"
+BOOTSTRAP_KERNEL="$BOOT_IMAGES_DIR/vmlinuz-$ARCH_SUFFIX"
+BOOTSTRAP_INITRD="$BOOT_IMAGES_DIR/initrd.img-$ARCH_SUFFIX"
###
function map_disk()
@@ -43,6 +47,9 @@ function bs_copy_conf_dir()
function bootstrap_fs()
{
+ test_file "$BOOTSTRAP_KERNEL" || fail_exit "Could'nt find bootstrap kernel : $BOOTSTRAP_KERNEL"
+ test_file "$BOOTSTRAP_INITRD" || fail_exit "Could'nt find bootstrap initrd : $BOOTSTRAP_KERNEL"
+
MNTDIR="`mktemp -d`"
CLEANUP+=("rmdir $MNTDIR")
local DISKDEV=$1
@@ -93,8 +100,8 @@ EOF
# Start VM to debootstrap, second stage
desc_update_setting "KVM_NETWORK_MODEL" "virtio"
- desc_update_setting "KVM_KERNEL" "/boot/vmlinuz-SV"
- desc_update_setting "KVM_INITRD" "/boot/initrd.img-SV"
+ desc_update_setting "KVM_KERNEL" "$BOOTSTRAP_KERNEL"
+ desc_update_setting "KVM_INITRD" "$BOOTSTRAP_INITRD"
desc_update_setting "KVM_APPEND" "root=$rootdev ro init=/bootstrap-init.sh"
kvm_start_vm "$VM_NAME"
diff --git a/kvm-wrapper.conf b/kvm-wrapper.conf
index 4af57fa..49fdbf6 100644
--- a/kvm-wrapper.conf
+++ b/kvm-wrapper.conf
@@ -17,7 +17,7 @@ NBD_IMG_LINK_DIR="$PID_DIR/nbd"
VM_DIR="$ROOTDIR/vm"
BOOTSTRAP_DIR="$ROOTDIR/bootstrap/"
-
+BOOT_IMAGES_DIR="/var/lib/kvm-wrapper/boot"
KVM_IMG_FORMAT="qcow2"
@@ -42,14 +42,18 @@ KVM_OUTPUT="-curses"
#KVM_INITRD
#KVM_APPEND
-#KVM_ADDITIONNAL_PARAMS
-
-#KVM_BIN
-
+# Bootstrap options
BOOTSTRAP_NET_GW="192.168.172.1"
BOOTSTRAP_NET_MASK="255.255.255.0"
BOOTSTRAP_NET_NW="192.168.172.0"
-
-VG_NAME="SV"
-LV_SIZE="3G"
+#BOOTSTRAP_NET_ADDR
BOOTSTRAP_DISTRIB="lenny"
+
+# LVM configuration
+LVM_VG_NAME="SV"
+LVM_LV_SIZE="3G"
+#LVM_LV_NAME
+
+#KVM_BIN
+#KVM_ADDITIONNAL_PARAMS
+
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 23d425d..0d58e25 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -191,7 +191,7 @@ function lvm_create_disk ()
test_file "$VM_DESCRIPTOR" || fail_exit "Couldn't open VM $VM_NAME descriptor :\n$VM_DESCRIPTOR"
source "$VM_DESCRIPTOR"
- eval $LVM_LVCREATE_BIN --name ${LV_NAME:-$VM_NAME} --size $LV_SIZE $VG_NAME
+ eval $LVM_LVCREATE_BIN --name ${LVM_LV_NAME:-"vm.$VM_NAME"} --size $LVM_LV_SIZE $LVM_VG_NAME
}
@@ -282,6 +282,7 @@ function kvm_start_vm ()
check_create_dir "$PID_DIR"
check_create_dir "$MONITOR_DIR"
check_create_dir "$SERIAL_DIR"
+ check_create_dir "$BOOT_IMAGES_DIR"
test_file "$VM_DESCRIPTOR" || fail_exit "Couldn't open VM $VM_NAME descriptor :\n$VM_DESCRIPTOR"
source "$VM_DESCRIPTOR"
@@ -540,10 +541,10 @@ function kvm_bootstrap_vm ()
local CLEANUP=( )
-
set +e
trap cleanup EXIT
+ require_exec "kpartx"
VM_NAME="$1"
VM_DESCRIPTOR="$VM_DIR/$VM_NAME-vm"