diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2020-08-20 22:28:49 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2020-08-20 22:28:49 -0300 |
commit | 55f2b7e29f9165280a4eda1348dca10e8474400b (patch) | |
tree | 33280191e605ee91576a185790b1f598a4dbecd5 | |
parent | 78224a66dcd529f8859016087aa34657de6154fe (diff) | |
download | kvmx-55f2b7e29f9165280a4eda1348dca10e8474400b.tar.gz kvmx-55f2b7e29f9165280a4eda1348dca10e8474400b.tar.bz2 |
Fix: kvmx_disposable: determine guest name using a sequential suffix
-rwxr-xr-x | kvmx | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -2185,8 +2185,32 @@ function kvmx_create { # Disposable guest function kvmx_disposable { - local date="`date +%Y%m%d%I%M%S`" - local disposable="$VM-disposable-$date" + # Determine guest name by appending the current date + # This approache leads to the following UNIX socket error + # if the VM name is too long: + # + # UNIX socket path '/var/cache/qemu/.../monitor' is too long + # Path must be less than 108 bytes + # + #local date="`date +%Y%m%d%I%M%S`" + #local disposable="$VM-disposable-$date" + + local disposable="$VM-disposable-" + local count=0 + + # Determine guest name using a sequential suffix + # + # This results in smaller guest names which are les prone to + # the UNIX socket path issue and also is easier to type + while true; do + disposable="${disposable}${count}" + if ! kvmx list_image ${disposable} &> /dev/null; then + break + fi + + echo $count + let count++ + done # Clone and ensure we use a backing file kvmx clone $VM $disposable --skell || exit 1 |