Introduce a new VIR_DOMAIN_EVENT_STOPPED_REBOOT detail for the 'stopped'
lifecycle event, which indicates a domain has stopped due to a host or domain
OS initiated reboot.

If domain "on_reboot" is not set to "restart", the listener can be aware
of such reboot request and run their own procedures.

Resolves: https://github.com/QubesOS/qubes-issues/issues/8196
Signed-off-by: Ben Grande <[email protected]>
---
 examples/c/misc/event-test.c     | 3 +++
 include/libvirt/libvirt-domain.h | 1 +
 tools/virsh-domain-event.c       | 3 ++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c
index 3e2b0a7827..1bac8d0cb8 100644
--- a/examples/c/misc/event-test.c
+++ b/examples/c/misc/event-test.c
@@ -239,6 +239,9 @@ eventDetailToString(int event,
             case VIR_DOMAIN_EVENT_STOPPED_RECREATED:
                 return "Recreated";
 
+            case VIR_DOMAIN_EVENT_STOPPED_REBOOT:
+                return "Reboot";
+
             case VIR_DOMAIN_EVENT_STOPPED_LAST:
                 break;
             }
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 9ee153c6eb..aa623f85b5 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -5778,6 +5778,7 @@ typedef enum {
     VIR_DOMAIN_EVENT_STOPPED_FAILED = 5,    /* Host emulator/mgmt failed 
(Since: 0.5.0) */
     VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT = 6, /* offline snapshot loaded 
(Since: 0.8.0) */
     VIR_DOMAIN_EVENT_STOPPED_RECREATED = 7,    /* Secure guest recreation 
(Since: 11.6.0) */
+    VIR_DOMAIN_EVENT_STOPPED_REBOOT = 8,    /* Host or guest requested reboot 
(Since: 12.10.0) */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_EVENT_STOPPED_LAST /* (Since: 0.9.10) */
diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c
index 0e408a11e8..9021cdc0f8 100644
--- a/tools/virsh-domain-event.c
+++ b/tools/virsh-domain-event.c
@@ -108,7 +108,8 @@ VIR_ENUM_IMPL(virshDomainEventStopped,
               N_("Saved"),
               N_("Failed"),
               N_("Snapshot"),
-              N_("Recreated"));
+              N_("Recreated"),
+              N_("Reboot"));
 
 VIR_ENUM_DECL(virshDomainEventShutdown);
 VIR_ENUM_IMPL(virshDomainEventShutdown,
-- 
Benjamin Grande

Reply via email to