aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/disk-image-builder/nested/image-patches
diff options
context:
space:
mode:
Diffstat (limited to 'resources/tools/disk-image-builder/nested/image-patches')
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/01-serial-console23
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/02-users37
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/03-network37
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/04-qemu-ga33
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/05-ssh-hostkeys11
-rwxr-xr-xresources/tools/disk-image-builder/nested/image-patches/06-dpdk-support78
6 files changed, 219 insertions, 0 deletions
diff --git a/resources/tools/disk-image-builder/nested/image-patches/01-serial-console b/resources/tools/disk-image-builder/nested/image-patches/01-serial-console
new file mode 100755
index 0000000000..99b6f7f3c8
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/01-serial-console
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+patch boot/grub/menu.lst <<"_EOF"
+2c2,4
+< timeout 10
+---
+> timeout 1
+> serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
+> terminal --timeout=0 serial console
+15c17
+< kernel /boot/bzImage rw root=/dev/sda1
+---
+> kernel /boot/bzImage rw root=/dev/sda1 console=ttyS0,115200n8
+_EOF
+
+patch etc/inittab <<"_EOF"
+27c27,29
+< console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
+---
+> console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
+> # ttyS1 to be used by qemu-ga
+> ttyS2::respawn:/sbin/getty -L ttyS2 0 vt100 # Additional serial
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/image-patches/02-users b/resources/tools/disk-image-builder/nested/image-patches/02-users
new file mode 100755
index 0000000000..9b7db0969a
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/02-users
@@ -0,0 +1,37 @@
+#!/bin/sh -e
+
+patch etc/sudoers <<"_EOF"
+97a98,100
+>
+> csit ALL=(root) NOPASSWD:ALL
+> cisco ALL=(root) NOPASSWD:ALL
+_EOF
+
+patch etc/passwd <<"_EOF"
+10a11,12
+> csit:x:1001:1001:CSIT user:/tmp:/bin/sh
+> cisco:x:1002:1002:Cisco user:/tmp:/bin/sh
+_EOF
+
+patch etc/shadow <<"_EOF"
+1c1
+< root::10933:0:99999:7:::
+---
+> root:5pcUkhKEiBBfw:16892:0:99999:7:::
+10a11,12
+> csit:5pcUkhKEiBBfw:16892:0:99999:7:::
+> cisco:5piAVSAyGsbaI:16892:0:99999:7:::
+_EOF
+
+patch etc/group <<"_EOF"
+27a28,29
+> csit:x:1001:
+> cisco:x:1002:
+_EOF
+
+patch etc/ssh/sshd_config <<"_EOF"
+44c44
+< #PermitRootLogin prohibit-password
+---
+> PermitRootLogin yes
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/image-patches/03-network b/resources/tools/disk-image-builder/nested/image-patches/03-network
new file mode 100755
index 0000000000..ca5c4f952d
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/03-network
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+patch boot/grub/menu.lst <<"_EOF"
+17c17
+< kernel /boot/bzImage rw root=/dev/sda1 console=ttyS0,115200n8
+---
+> kernel /boot/bzImage rw root=/dev/sda1 ipv6.disable=1 console=ttyS0,115200n8
+_EOF
+
+patch etc/network/interfaces <<"_EOF"
+4a5,7
+>
+> auto mgmt0
+> iface mgmt0 inet dhcp
+_EOF
+
+patch etc/init.d/S40network <<"_EOF"
+11a12,29
+>
+> # Rename interfaces. The e1000 interface is managment.
+> NUM_VIRTIO=0
+> NUM_MGMT=0
+> for dev in /sys/class/net/eth*
+> do
+> devname=`basename $dev`
+> driver=`readlink ${dev}/device/driver`
+> if test "${driver#*virtio}" != "$driver"
+> then
+> ip link set dev $devname name virtio${NUM_VIRTIO}
+> NUM_VIRTIO=$(($NUM_VIRTIO+1))
+> else
+> ip link set dev $devname name mgmt${NUM_MGMT}
+> NUM_MGMT=$((NUM_MGMT+1))
+> fi
+> done
+>
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/image-patches/04-qemu-ga b/resources/tools/disk-image-builder/nested/image-patches/04-qemu-ga
new file mode 100755
index 0000000000..2897260d10
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/04-qemu-ga
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+cat - > etc/init.d/S45qemu-ga <<"_EOF"
+#!/bin/sh
+#
+# Start QEMU guest agent
+#
+QEMU_GA_MODE="isa-serial"
+QEMU_GA_DEV="/dev/ttyS1"
+
+case "$1" in
+ start)
+ echo "Starting qemu guest agent..."
+ /usr/bin/qemu-ga -m $QEMU_GA_MODE -p $QEMU_GA_DEV -d
+ ;;
+ stop)
+ echo "Stopping quemu guest agent..."
+ killall qemu-ga
+ ;;
+ restart|reload)
+ "$0" stop
+ "$0" start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
+_EOF
+
+chown root.root etc/init.d/S45qemu-ga
+chmod 755 etc/init.d/S45qemu-ga
diff --git a/resources/tools/disk-image-builder/nested/image-patches/05-ssh-hostkeys b/resources/tools/disk-image-builder/nested/image-patches/05-ssh-hostkeys
new file mode 100755
index 0000000000..de8be15798
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/05-ssh-hostkeys
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Generate host keys here. This will speed up first boot time ever so slightly.
+# It does however mean that keys are not unique across installations -- which
+# shouldn't be an issue for our use case though.
+
+sudo mkdir -m 0775 -p etc/ssh
+for a in rsa ecdsa ed25519 dsa
+do
+ sudo ssh-keygen -f etc/ssh/ssh_host_${a}_key -N "" -t ${a}
+done
diff --git a/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support b/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support
new file mode 100755
index 0000000000..99ac0e14e3
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/image-patches/06-dpdk-support
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+### This may be a temporary file. Once DPDK is working stable in the nested
+### VM, and if and when ### we decide we want to do all testing with DPDK,
+### the steps executed here may become default configuration for the image.
+###
+### For now, to give us the flexibility to work with and without DPDK, keep
+### this as a separate script.
+
+DPDK_START_FILE="start-testpmd.sh"
+DPDK_STOP_FILE="stop-testpmd.sh"
+
+cat - > ${DPDK_START_FILE} <<"_EOF"
+#!/bin/sh
+
+TARGET_DRIVER="igb_uio"
+PATH_TO_IGB_UIO_MODULE="/usr/local/kmod/igb_uio.ko"
+NUM_HUGEPAGES=512
+TESTPMD_LOG=/tmp/testpmd.log
+TESTPMD_PID=/tmp/testpmd.pid
+
+if [ -f ${TESTPMD_PID} ]
+then
+ echo Testpmd is already running. Please stop running instance first.
+ echo Delete PID file ${TESTPMD_PID} if you are sure this is a stale PID file.
+ exit 1
+fi
+
+# Load igb_uio module if this is the driver we want to use
+if [ "${TARGET_DRIVER}" = "igb_uio" ]
+then
+ insmod ${PATH_TO_IGB_UIO_MODULE}
+fi
+
+# Set up hugepages
+echo "vm.nr_hugepages = ${NUM_HUGEPAGES}" > /etc/sysctl.conf
+sysctl -p
+mkdir -p /mnt/huge
+grep -q hugetlbfs /etc/fstab || echo "hugetlbfs /mnt/huge hugetlbfs mode=1770,gid=2021 0 0" >> /etc/fstab
+mount -a
+
+#
+echo 1af4 1000 > /sys/bus/pci/drivers/${TARGET_DRIVER}/new_id
+#
+for dev in $(find /sys/bus/pci/drivers/virtio-pci -type l -name '*:*:*.*' | sed -e 's/.*\///')
+do
+ echo Unbinding $dev from virtio-pci
+ echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
+ echo Binding $dev to ${TARGET_DRIVER}
+ echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
+done
+
+# Start testpmd in the background. This looks a bit convoluted; we need to redirect stdin
+# (and keep stdin active) or else testpmd will quit.
+tail -f /dev/null | nohup testpmd $@ > ${TESTPMD_LOG} 2>&1 &
+echo $! > ${TESTPMD_PID}
+_EOF
+
+cat - > ${DPDK_STOP_FILE} <<"_EOF"
+#!/bin/sh
+
+TESTPMD_LOG=/tmp/testpmd.log
+TESTPMD_PID=/tmp/testpmd.pid
+
+if [ ! -f ${TESTPMD_PID} ]
+then
+ echo Testpmd is not running.
+ exit 1
+fi
+
+kill $(cat ${TESTPMD_PID})
+rm -f ${TESTPMD_PID}
+
+cat ${TESTPMD_LOG}
+_EOF
+
+chmod 755 ${DPDK_START_FILE}
+chmod 755 ${DPDK_STOP_FILE}