[PATCH v2 0/9] Add stopped reason for reboot
Report the new VIR_DOMAIN_EVENT_STOPPED_REBOOT reason when reboot has been requested. I have only tested this on Xen, so I made a patch per VMM. I preferred to rely on the stopped reason, as there is no discussion that it should be sent, while for the reboot event, there is debate that it shouldn't always be sent. CI: https://gitlab.com/libvirt/libvirt/-/merge_requests/567 Previous discussion and patches: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/ZB5AL... https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/KYAL4... Ben Grande (9): libvirt-domain: Add stopped reason of reboot docs: libvirt-domain: briefly document reboot event virsh: Add reboot to event enum libxl: Propagate stopped reason of reboot lxc_process: Propagate stopped reason of reboot test_driver: Propagate stopped reason of reboot examples: Add event detail reboot for stopped event NEWS: Introduce VIR_DOMAIN_EVENT_STOPPED_REASON NEWS: Inform drivers that support reboot reason NEWS.rst | 8 ++++++++ examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 4 +++- src/libxl/libxl_domain.c | 2 +- src/lxc/lxc_process.c | 2 +- src/test/test_driver.c | 2 +- tools/virsh-domain-event.c | 3 ++- 8 files changed, 20 insertions(+), 5 deletions(-) -- Benjamin Grande
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 <ben@invisiblethingslab.com> --- include/libvirt/libvirt-domain.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 99208137c3..6000026b4d 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5777,6 +5777,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.9.0) */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_STOPPED_LAST /* (Since: 0.9.10) */ -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/libvirt-domain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index acd9ffc44b..95764ebd2b 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1779,7 +1779,9 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) * Note that the guest OS may ignore the request. * Additionally, the hypervisor may check and support the domain * 'on_reboot' XML setting resulting in a domain that shuts down instead - * of rebooting. + * of rebooting. Depending on the hypervisor and 'on_reboot' setting, + * VIR_DOMAIN_EVENT_ID_REBOOT might be emitted. For more information, see + * https://libvirt.org/formatdomain.html#events-configuration * * If @flags is set to zero, then the hypervisor will choose the * method of shutdown it considers best. To have greater control -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- tools/virsh-domain-event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index a541b155f4..3a1e7ea429 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -107,7 +107,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
Resolves: https://github.com/QubesOS/qubes-issues/issues/8196 Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/libxl/libxl_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 51dc3edcc2..808a8a333c 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -547,7 +547,7 @@ libxlDomainShutdownThread(void *opaque) dom_event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); + VIR_DOMAIN_EVENT_STOPPED_REBOOT); switch ((virDomainLifecycleAction) vm->def->onReboot) { case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: libxlDomainShutdownHandleDestroy(driver, vm); -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/lxc/lxc_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 466ce07afd..b9fa21a815 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -727,7 +727,7 @@ static void virLXCProcessMonitorExitNotify(virLXCMonitor *mon G_GNUC_UNUSED, priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED; break; case VIR_LXC_MONITOR_EXIT_STATUS_REBOOT: - priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN; + priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_REBOOT; priv->wantReboot = true; break; default: -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/test/test_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8546c3e251..fbde51f3e4 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2076,7 +2076,7 @@ static int testDomainReboot(virDomainPtr domain, testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); event = virDomainEventLifecycleNewFromObj(privdom, VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); + VIR_DOMAIN_EVENT_STOPPED_REBOOT); if (!privdom->persistent) virDomainObjListRemove(privconn->domains, privdom); -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- examples/c/misc/event-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 601f5eafcf..d7b11a61d9 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -236,6 +236,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; } -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- NEWS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 6ffc803118..f3576ac3d3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,8 @@ v12.9.0 (unreleased) * **New features** + * Introduce ``VIR_DOMAIN_EVENT_STOPPED_REBOOT`` event reason. + * **Improvements** * **Bug fixes** -- Benjamin Grande
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index f3576ac3d3..6af1ab5957 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -21,6 +21,12 @@ v12.9.0 (unreleased) * **Improvements** + * lxc: Report reboot reason ``VIR_DOMAIN_EVENT_STOPPED_REBOOT``. + + * libxl: Report reboot reason ``VIR_DOMAIN_EVENT_STOPPED_REBOOT``. + + * test driver: Report reboot reason ``VIR_DOMAIN_EVENT_STOPPED_REBOOT``. + * **Bug fixes** -- Benjamin Grande
participants (1)
-
Ben Grande