Since processing running VMs on OS shutdown can take a while, it is
beneficial to send systemd status messages about the progress.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
src/hypervisor/domain_driver.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index 2f89b8c841..421cc16574 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -30,6 +30,7 @@
#include "datatypes.h"
#include "driver.h"
#include "virlog.h"
+#include "virsystemd.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@@ -791,6 +792,8 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg)
(!transient[i] && cfg->trySave == VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_TRANSIENT))
continue;
+ virSystemdNotifyStatus("Suspending '%s' (%zu of %d)",
+ virDomainGetName(domains[i]), i + 1, numDomains);
/*
* Pause all VMs to make them stop dirtying pages,
* so save is quicker. We remember if any VMs were
@@ -808,6 +811,9 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg)
}
for (i = 0; i < numDomains; i++) {
+ virSystemdNotifyStatus("Saving '%s' (%zu of %d)",
+ virDomainGetName(domains[i]), i + 1, numDomains);
+
if (virDomainManagedSave(domains[i], flags[i]) < 0) {
VIR_WARN("Unable to perform managed save of '%s': %s",
virDomainGetName(domains[i]),
@@ -829,6 +835,9 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg)
(!transient[i] && cfg->tryShutdown == VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_TRANSIENT))
continue;
+ virSystemdNotifyStatus("Shutting down '%s' (%zu of %d)",
+ virDomainGetName(domains[i]), i + 1, numDomains);
+
if (virDomainShutdown(domains[i]) < 0) {
VIR_WARN("Unable to perform graceful shutdown of '%s': %s",
virDomainGetName(domains[i]),
@@ -838,6 +847,8 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg)
}
timer = g_timer_new();
+ virSystemdNotifyStatus("Waiting %d secs for VM shutdown completion",
+ cfg->waitShutdownSecs);
while (1) {
bool anyRunning = false;
for (i = 0; i < numDomains; i++) {
@@ -874,10 +885,14 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg)
(!transient[i] && cfg->poweroff == VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_TRANSIENT))
continue;
+ virSystemdNotifyStatus("Destroying '%s' (%zu of %d)",
+ virDomainGetName(domains[i]), i + 1, numDomains);
virDomainDestroy(domains[i]);
}
}
+ virSystemdNotifyStatus("Processed %d domains", numDomains);
+
cleanup:
if (domains) {
for (i = 0; i < numDomains; i++) {
--
2.47.1