=== modified file 'bin/run-adt-test' --- bin/run-adt-test 2013-07-11 08:28:12 +0000 +++ bin/run-adt-test 2013-08-01 10:32:05 +0000 @@ -69,6 +69,7 @@ kill -9 $(cat $BCKPATH.pid) rm -f $BCKPATH.pid rm -f $BCKPATH + rm -f $BCKPATH.monitor fi rm -f $LOCKDIR/ssh.$SSHPORT.lock @@ -240,11 +241,15 @@ VNCKVM=$((VNCPORT - 5900)) log_info_msg "Starting $BCKNAME on port $SSHPORT" -$EATMYDATA $KVMCMD $CPUMODEL -m $RAMSIZE -smp $VCPU -monitor stdio \ +$EATMYDATA $KVMCMD $CPUMODEL -m $RAMSIZE -smp $VCPU -monitor unix:${BCKPATH}.monitor,server,nowait \ -localtime -no-reboot -net user -redir tcp:$SSHPORT::22 \ - -drive file=$BCKPATH,if=virtio -drive file=$SEED,if=virtio \ + -drive file=$BCKPATH,if=virtio,index=0 \ + -drive file=$SEED,if=virtio,index=1,readonly \ -vnc localhost:$VNCKVM -pidfile $BCKPATH.pid -readconfig $VMCFG & +# adjust to ordering/number of -drive arguments from above +CLOUD_CONFIG_DEV=/dev/vdb + log_info_msg "Waiting for VM to startup" LOOP=0 while :; do @@ -288,8 +293,29 @@ ssh $SSHOPTS -p $SSHPORT -tt -o BatchMode=yes -l ubuntu localhost "echo '$TZ' | sudo tee /etc/timezone; sudo dpkg-reconfigure -pcritical tzdata" fi +# set up pristine VM device; we need to hotplug that to avoid confusing +# initramfs/cloud-init about having two seemingly identical (UUID/label) disks +# during boot +log_info_msg "Making pristine VM available as /dev/pristine_vm for nested VMs" +PRISTINE_VM_DEV=/dev/vdc # keep in sync with index=# below +echo "pci_add auto storage file=$DISKPATH,if=virtio,index=2,readonly" | nc -U -q 0 ${BCKPATH}.monitor >/dev/null + +ssh $SSHOPTS -p $SSHPORT -tt -o BatchMode=yes -l ubuntu localhost " +while [ ! -e $PRISTINE_VM_DEV ]; do sleep 0.1; done; +sudo chmod 444 $CLOUD_CONFIG_DEV $PRISTINE_VM_DEV*; +sudo ln -s $PRISTINE_VM_DEV /dev/pristine_vm; +sudo ln -s $CLOUD_CONFIG_DEV /dev/cloud_config; +sudo addgroup --system kvm; +sudo adduser ubuntu kvm; +" + +# copy ssh key into VM so that we can use it in sub-VMs +scp $SSHOPTS -qpr -P $SSHPORT "$KEYPATH" ubuntu@localhost:.ssh/id_rsa || true +scp $SSHOPTS -qpr -P $SSHPORT "$KEYPATH.pub" ubuntu@localhost:.ssh/id_rsa.pub || true + # Upload local source directory to sandbox if [ "$( echo $SRC_LOCATION | cut -c-7)" = "file://" ]; then + log_info_msg "Copying local source directory into VM" LOCALDIR="$(echo $SRC_LOCATION | cut -c8-)" scp $SSHOPTS -qpr -P $SSHPORT "$LOCALDIR" ubuntu@localhost:$TESTBED_WORKDIR/ || true if [ $? -gt 0 ]; then