From f7f159a04671690786de2f84e34046c103521d58 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Dec 2024 19:03:49 +0800 Subject: vm.shupdate --- others/vm3/compute/start.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) mode change 100644 => 100755 others/vm3/compute/start.sh (limited to 'others/vm3/compute/start.sh') diff --git a/others/vm3/compute/start.sh b/others/vm3/compute/start.sh old mode 100644 new mode 100755 index 5a2b3aa..d64dbb1 --- a/others/vm3/compute/start.sh +++ b/others/vm3/compute/start.sh @@ -1,4 +1,20 @@ #!/bin/bash # starts vm -# need to remove seed.iso first if vm have the seed iso +# remove seed.iso first if vm have the seed iso + +vmname=$1 + +# Get the target device for seed.iso +target_dev=$(sudo virsh domblklist $vmname | grep 'seed.iso' | awk '{print $1}') + +# If seed.iso is found, detach it, +# --config means it is persistent but do not affect the state now. +# --config --live means online remove +# no option means that the changes are not persistent +# +if [ ! -z "$target_dev" ]; then + sudo virsh detach-disk $vmname $target_dev --config +fi + +sudo virsh start $vmname -- cgit v1.2.3-70-g09d2