Skip to content

Commit

Permalink
kiss-vm: improve _vmdelete() code
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhong Yin <[email protected]>
  • Loading branch information
tcler committed May 8, 2021
1 parent 1a81ea2 commit 943a8d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions kiss-vm
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ _vmdelete() {
fi

echo -e "\n{VM:INFO} => dist removing VM $_vmname .."
virsh destroy $_vmname 2>/dev/null
sleep 1
virsh undefine $_vmname --remove-all-storage --nvram
virsh destroy $_vmname 2>/dev/null; sleep 0.5
_std=$(virsh undefine $_vmname --remove-all-storage --nvram 2>&1)
if grep -q "error: Refusing to undefine while domain managed save image exists" <(echo "$_std"); then
virsh managedsave-remove $_vmname 2>/dev/null
virsh undefine $_vmname --remove-all-storage --nvram
else
echo "$_std"
fi

if [[ "$_vmdir" = $VMSHOME/?*/$_vmname ]]; then
echo -e "- {VM:INFO} removing VM folder $_vmdir ..."
rm -f $_vmdir/{url,nohup.log,ext4.qcow2,xfs.qcow2,vm.xml,qemu.argv,.kiss-vm}
Expand Down

0 comments on commit 943a8d8

Please sign in to comment.