Use --managed-save flag to virsh undefine
If a virtual machine has got a managed save image, it is not
possible to delete it using a plain 'virsh undefine' command.
While Nova doesn't use 'managed save', the libvirt-guests
init script or systemd service may have created one if the
user rebooted their host. Thus we devstack should pass the
--managed-save flag to virsh to ensure the VM's removal.
Change-Id: Id9b072a6dceeb4e179d2b6a25bbdfb559c299e95
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
diff --git a/lib/nova b/lib/nova
index 6fc0c79..9fc4ded 100644
--- a/lib/nova
+++ b/lib/nova
@@ -151,7 +151,7 @@
instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
if [ ! "$instances" = "" ]; then
echo $instances | xargs -n1 sudo virsh destroy || true
- echo $instances | xargs -n1 sudo virsh undefine || true
+ echo $instances | xargs -n1 sudo virsh undefine --managed-save || true
fi
# Logout and delete iscsi sessions