diff --git a/src/cron-callback.sh b/src/cron-callback.sh index 441977c0c5aa22dee64b4683a82b681f8443fdb8..69c312039fd0fab714cb2944a02d09e5d242bfb9 100644 --- a/src/cron-callback.sh +++ b/src/cron-callback.sh @@ -37,7 +37,9 @@ ssh_pwauth: True function download_cloud_img_if_not_exist () { local cloudimg="$1" [[ "$1" != "focal-server-cloudimg-amd64.img" ]] && echo2 "ERROR: cloudimg not supported" - [[ -f "base/$cloudimg" ]] || aria2c -o "base/$cloudimg" https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img || ! echo2 "Failed to download ubuntu cloudimg" || return $? + [[ -f "base/$cloudimg" ]] && return + echo2 "+ Downloading cloudimg $cloudimg..." + aria2c -o "base/$cloudimg" https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img || ! echo2 "Failed to download ubuntu cloudimg" || return $? } function create_vm_if_not_exist () { @@ -55,6 +57,7 @@ function create_vm_if_not_exist () { download_cloud_img_if_not_exist "$cloudimg" || return $? rm -rf "vm/$name" ; mkdir -p "vm/$name" # create it + echo2 "+ Creating VM image $name with options $@..." generate_metadata "$name" > "vm/$name/meta-data" || return $? generate_userdata "$username" "$password" "$name" > "vm/$name/user-data" || return $? ( cd "vm/$name" ; genisoimage -output initimg.iso -volid cidata -joliet -rock user-data meta-data ) || return $? @@ -72,11 +75,12 @@ function start_vm_if_not_running () { local uuid=`uuidgen --namespace @oid --name "qemu.$name" --sha1` # Check if qemu already running for this instance. - ps aux | grep -F "--uuid $uuid" | grep qemu && return 0 + ps aux | grep -F "uuid $uuid" | grep qemu && return 0 # start it [[ ! -f "vm/$name/disk.img" ]] && echo2 "In start_vm, disk image vm/$name/disk.img doesn't exist. Did init_vm fail?" && return 1 - nohup qemu-system-x86_64 --uuid "$uuid" -drive file="vm/$name/disk.img",if=virtio -cdrom "vm/$name/initimg.iso" -cpu host --enable-kvm -bios /usr/share/edk2-ovmf/x64/OVMF.fd -net nic,model=rtl8139 "${options[@]}" & disown + echo2 "+ Starting VM $name with options_txt '$options_txt' and uuid $uuid..." + nohup qemu-system-x86_64 --uuid "$uuid" -drive file="vm/$name/disk.img",if=virtio -cdrom "vm/$name/initimg.iso" -cpu host --enable-kvm -bios /usr/share/edk2-ovmf/x64/OVMF.fd -net nic,model=rtl8139 "${options[@]}" >> tmp/qemu.log 2>&1 & disown } function do_init () { diff --git a/src/runtime.settings b/src/runtime.settings index bfd56dbb620dce335e1a27e6926d90a41481ec99..43bbd4c23cd95eb6b16a0ed7ac7e94753d77f85d 100644 --- a/src/runtime.settings +++ b/src/runtime.settings @@ -1,4 +1,4 @@ # name;options (name will be trimmed, options will be passed as-is) -instance1;-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30472-:22 +instance1;-m 2G -smp 2 -vnc :11 -net user,hostfwd=tcp::30471-:22 #gitlab-ci;-m 4G -smp 4 -vnc :12 -net user,hostfwd=tcp::30473-:22 #httptest ;-m 1G -smp 1 -vnc :13 -net user,hostfwd=tcp::30474-:22