Update upon suggestion:
According to the blog/wiki author:
However, there is the problem that each VM will only receive one shutdown request. For Linux VMs this is usually fine, but Windows VMs sometimes do not react to the first request, resulting in the VM being killed forcibly after the timeout. The only way to fix this problem is modifying the shutdown script so that it sends shutdown requests again and again until a VM has shutdown or the timeout has been reached.
So the solution is to patch /usr/lib/libvirt/libvirt-guests.sh
in Ubuntu 16.04 LTS (Xenial Xerus) (credit to the wiki author: Sebastian Marsching):
--- /usr/lib/libvirt/libvirt-guests.sh 2016-10-10 09:33:38.000000000 +0200
+++ /usr/local/lib/libvirt/libvirt-guests.sh 2016-11-08 11:58:33.000000000 +0100
@@ -339,6 +339,19 @@
retval run_virsh "$uri" shutdown "$guest" > /dev/null
}
+# shutdown_guest_retry URI GUEST
+# Start a ACPI shutdown of GUEST on URI. This function returns after the command
+# was issued to libvirt to allow parallel shutdown.
+# This command does the same as shutdown_guest_async, but does not print a
+# message.
+shutdown_guest_retry()
+{
+ uri=$1
+ guest=$2
+
+ retval run_virsh "$uri" shutdown "$guest" > /dev/null
+}
+
# guest_count GUEST_LIST
# Returns number of guests in GUEST_LIST
guest_count()
@@ -407,6 +420,14 @@
format=$(eval_gettext "Waiting for %d guests to shut down\n")
fi
while [ -n "$on_shutdown" ] || [ -n "$guests" ]; do
+ guests_retry=$on_shutdown
+ while [ -n "$guests_retry" ]; do
+ set -- $guests_retry
+ guest=$1
+ shift
+ guests_retry=$*
+ shutdown_guest_retry "$uri" "$guest"
+ done
while [ -n "$guests" ] &&
[ $(guest_count "$on_shutdown") -lt "$PARALLEL_SHUTDOWN" ]; do
set -- $guests
However, when I checked the same code for Ubuntu 20.04, the similar logic is already there. So this is no longer a problem.
It is late as an answer, but it is useful for documenting:
This post gives a solution for Ubuntu.