| 1 | #!/bin/bash
|
|---|
| 2 | set -e
|
|---|
| 3 | set -x
|
|---|
| 4 | vmname='VHDBUG'
|
|---|
| 5 | rootdir="${HOME}/VirtualBox VMs/${vmname}"
|
|---|
| 6 |
|
|---|
| 7 | # The bug doesn't happen when this line is commented.
|
|---|
| 8 | wait='true'
|
|---|
| 9 |
|
|---|
| 10 | # Abort if there is a VBoxSVC process already running
|
|---|
| 11 | killall -0 -v VBoxSVC && exit 1 || true
|
|---|
| 12 |
|
|---|
| 13 | mkdir -pv "${rootdir}"
|
|---|
| 14 |
|
|---|
| 15 | VBoxManage createmedium disk --filename "${rootdir}/basedisk.vhd" --size 1024 --format VHD
|
|---|
| 16 | test -z "${wait}" || killall -0 -w VBoxSVC
|
|---|
| 17 |
|
|---|
| 18 | VBoxManage internalcommands dumphdinfo "${rootdir}/basedisk.vhd"
|
|---|
| 19 | VBoxManage createmedium disk --filename "${rootdir}/diffdisk.vhd" --diffparent "${rootdir}/basedisk.vhd"
|
|---|
| 20 | test -z "${wait}" || killall -0 -w VBoxSVC
|
|---|
| 21 |
|
|---|
| 22 | VBoxManage internalcommands dumphdinfo "${rootdir}/diffdisk.vhd"
|
|---|
| 23 | VBoxManage createmedium disk --filename "${rootdir}/diffdiffdisk.vhd" --diffparent "${rootdir}/diffdisk.vhd"
|
|---|
| 24 | test -z "${wait}" || killall -0 -w VBoxSVC
|
|---|
| 25 |
|
|---|
| 26 | VBoxManage internalcommands dumphdinfo "${rootdir}/diffdiffdisk.vhd"
|
|---|
| 27 | VBoxManage createvm --name "${vmname}" --basefolder "${rootdir}" --ostype Other_64 --register
|
|---|
| 28 | VBoxManage storagectl "${vmname}" --name SATA --add sata --portcount 4
|
|---|
| 29 | VBoxManage storageattach "${vmname}" --storagectl SATA --port 0 --type hdd --medium "${rootdir}/diffdiffdisk.vhd"
|
|---|
| 30 | test -z "${wait}" || killall -0 -w VBoxSVC
|
|---|
| 31 |
|
|---|
| 32 | VBoxManage showvminfo "${vmname}"
|
|---|
| 33 | test -z "${wait}" || killall -0 -w VBoxSVC
|
|---|
| 34 |
|
|---|
| 35 | VBoxManage unregistervm "${vmname}" --delete
|
|---|
| 36 | test -f "${rootdir}/diffdiffdisk.vhd" && VBoxManage closemedium disk "${rootdir}/diffdiffdisk.vhd" --delete || true
|
|---|
| 37 | test -f "${rootdir}/diffdisk.vhd" && VBoxManage closemedium disk "${rootdir}/diffdisk.vhd" --delete || true
|
|---|
| 38 | test -f "${rootdir}/basedisk.vhd" && VBoxManage closemedium disk "${rootdir}/basedisk.vhd" --delete || true
|
|---|
| 39 | killall -0 -w VBoxSVC || true
|
|---|
| 40 |
|
|---|
| 41 | echo 'Test ended successfully'
|
|---|