1
0
mirror of https://github.com/rancher/os.git synced 2025-09-04 00:04:25 +00:00

Hook cloud-config into qemu-system-aarch46

This commit is contained in:
Ivan Mikushin
2016-03-23 13:28:05 -07:00
parent 29aff3d807
commit 99c3207b14
2 changed files with 49 additions and 53 deletions

View File

@@ -76,3 +76,6 @@ RUN if [ "${TOOLCHAIN}" != "" ]; then \
make -j$(nproc) && \ make -j$(nproc) && \
make install \ make install \
;fi ;fi
RUN apt-get update && \
apt-get -y install dosfstools

View File

@@ -23,10 +23,18 @@ hd_amd64() {
echo "-drive if=virtio,file=$1" echo "-drive if=virtio,file=$1"
} }
hd_arm() { hd_arm() {
echo "-drive if=none,file=$1,id=hd0 -device virtio-blk-device,drive=hd0" echo "-drive if=none,id=hd0,file=$1 -device virtio-blk-device,drive=hd0"
} }
declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" ) declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" )
cd_amd64() {
echo "-hdc $1"
}
cd_arm() {
echo "-drive if=none,id=cd0,file=$1 -device virtio-blk-device,drive=cd0"
}
declare -A cd=( ["amd64"]="cd_amd64" ["arm"]="cd_arm" ["arm64"]="cd_arm" )
BASE=$(pwd) BASE=$(pwd)
UNAME=$(uname) UNAME=$(uname)
@@ -56,12 +64,6 @@ while [ "$#" -gt 0 ]; do
exit 1 exit 1
fi fi
;; ;;
--xhyve)
if [ -x $(which xhyve) ]; then
XHYVE=1
QEMU=0
fi
;;
--arch) --arch)
shift 1 shift 1
ARCH="$1" ARCH="$1"
@@ -152,18 +154,28 @@ if [ "$KVM" == "" ] && [ -c /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ]; th
KVM=1 KVM=1
fi fi
if [ "$XHYVE" == "1" ] || [ "$QEMU" == "1" ]; then if [ "$QEMU" == "1" ]; then
HD=${BASE}/state/hd.img HD=${BASE}/state/hd.img
[ "$FRESH" == "1" ] && rm -f ${HD} >/dev/null 2>&1 || : [ "$FRESH" == "1" ] && rm -f ${HD} >/dev/null 2>&1 || :
if [ ! -e ${HD} ]; then if [ ! -e ${HD} ]; then
mkdir -p $(dirname ${HD}) mkdir -p $(dirname ${HD})
if [ "$XHYVE" == "1" ]; then qemu-img create -f raw -o size=10G ${HD} qemu-img create -f qcow2 -o size=10G ${HD}
else qemu-img create -f qcow2 -o size=10G ${HD}
fi
fi fi
USER_DATA=${BUILD}/cloud-config/openstack/latest/user_data
CCIMG=${BUILD}/cc.img
CCDEV=$(losetup -f)
CCROOT=${BUILD}/cloud-config
dd if=/dev/zero of=${CCIMG} bs=1024 count=512
losetup ${CCDEV} ${CCIMG}
mkfs.vfat -n "config-2" ${CCDEV}
rm -rf ${CCROOT}
mkdir -p ${CCROOT}
mount ${CCDEV} ${CCROOT}
USER_DATA=${CCROOT}/openstack/latest/user_data
mkdir -p $(dirname ${USER_DATA}) mkdir -p $(dirname ${USER_DATA})
rm -f ${USER_DATA} || : rm -f ${USER_DATA} || :
if [ -n "$CLOUD_CONFIG" ]; then if [ -n "$CLOUD_CONFIG" ]; then
@@ -174,50 +186,31 @@ if [ "$XHYVE" == "1" ] || [ "$QEMU" == "1" ]; then
echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA} echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA}
fi fi
CLOUD_CONFIG_ISO="${BUILD}/cloud-config.iso" umount ${CCROOT}
rm -rf ${CLOUD_CONFIG_ISO} losetup -d ${CCDEV}
mkisofs -R -V config-2 -o "${CLOUD_CONFIG_ISO}" "$BUILD/cloud-config"
if [ "$XHYVE" == "1" ]; then
exec sudo -n xhyve -A -H -P -u \ CPU=${cpu["$ARCH"]}
-m 4G \ if [ "$KVM" == "1" ] && [ "$ARCH" == "$HOST_ARCH" ]; then
-s 0:0,hostbridge -s 31,lpc \ KVM_ENABLE="-enable-kvm"
-l com1,stdio \ CPU="-cpu host"
-s 2:0,virtio-net \
-s 3,ahci-cd,${CLOUD_CONFIG_ISO} \
-s 4,virtio-blk,${HD} \
-U a01fb25c-3a19-4759-a47a-2e353e51807d \
-f kexec,${KERNEL},${INITRD},"earlyprintk=serial elevator=noop ${KERNEL_ARGS}" \
"${@}"
elif [ "$QEMU" == "1" ]; then
CPU=${cpu["$ARCH"]}
if [ "$KVM" == "1" ] && [ "$ARCH" == "$HOST_ARCH" ]; then
KVM_ENABLE="-enable-kvm"
CPU="-cpu host"
fi
exec qemu-system-${QEMUARCH} -serial stdio \
${KVM_ENABLE} \
${CPU} \
${machine["$ARCH"]} \
-kernel ${KERNEL} \
-initrd ${INITRD} \
-m 1024 \
${network["$ARCH"]} \
$(eval "${hd["$ARCH"]} ${HD}") \
-smp 1 \
-cdrom ${CLOUD_CONFIG_ISO} \
-append "${KERNEL_ARGS}" \
-nographic \
-display none \
${QEMU_ARGS} \
"${@}"
else
exit 42
fi fi
exec qemu-system-${QEMUARCH} -serial stdio \
${KVM_ENABLE} \
${CPU} \
${machine["$ARCH"]} \
-kernel ${KERNEL} \
-initrd ${INITRD} \
-m 1024 \
${network["$ARCH"]} \
$(eval "${cd["$ARCH"]} ${CCIMG}") \
$(eval "${hd["$ARCH"]} ${HD}") \
-smp 1 \
-append "${KERNEL_ARGS}" \
-nographic \
-display none \
${QEMU_ARGS} \
"${@}"
elif [ "$QIND" == "1" ]; then elif [ "$QIND" == "1" ]; then