[PATCH v3 0/4] Add reboot stopped reason
Report the new VIR_DOMAIN_EVENT_STOPPED_REBOOT reason when reboot has been requested. I have only tested this on Xen. 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... https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/5W4TO... Ben Grande (4): libvirt: Add stopped reason of reboot docs: libvirt-domain: briefly document reboot event drivers: Propagate stopped reason of reboot NEWS: Introduce VIR_DOMAIN_EVENT_STOPPED_REASON NEWS.rst | 12 ++++++++++++ examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 5 ++++- 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, 25 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> --- 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..ada0df65a7 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.9.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
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/libvirt-domain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index acd9ffc44b..f1d4a30c2e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1779,7 +1779,10 @@ 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. When 'on_reboot' isn't 'restart', drivers that support it will + * emit a VIR_DOMAIN_EVENT_STOPPED lifecycle event with detail + * VIR_DOMAIN_EVENT_STOPPED_REBOOT. 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
Resolves: https://github.com/QubesOS/qubes-issues/issues/8196 Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/libxl/libxl_domain.c | 2 +- src/lxc/lxc_process.c | 2 +- src/test/test_driver.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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); 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: 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> --- NEWS.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 802f89190a..f553e49869 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,8 +33,20 @@ v12.10.0 (unreleased) width reported to the guest. This allows the apparent bandwidth of a passed-through device to match the host hardware. + * Introduce ``VIR_DOMAIN_EVENT_STOPPED_REBOOT`` event reason, which + + Extract the shutdown reason from the hypervisor, and in case the domain + asked for reboot, the event ``VIR_DOMAIN_EVENT_STOPPED`` will have the + detail type ``VIR_DOMAIN_EVENT_STOPPED_REBOOT``. + * **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
On 26-11-09 11:40:07, Ben Grande wrote:
Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- NEWS.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst index 802f89190a..f553e49869 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,8 +33,20 @@ v12.10.0 (unreleased) width reported to the guest. This allows the apparent bandwidth of a passed-through device to match the host hardware.
+ * Introduce ``VIR_DOMAIN_EVENT_STOPPED_REBOOT`` event reason, which
Uh... I did fix the end of the line, but didn't send the email with the correct patch. Sorry. Will submit all patches again. -- Best regards, Benjamin Grande Invisible Things Lab
participants (1)
-
Ben Grande