[PATCH v5 0/3] Add stopped reason of reboot
Report the new VIR_DOMAIN_EVENT_STOPPED_REBOOT reason when reboot has been requested. 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... https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/F2HQY... Since last discussion, I: - Fixed commit titles, to use the term "detail" instead of "reason"; - Fixed commit messages, to better describe what was done instead of only how the user should use it. I used the proposed messages from Jim without changes, as I didn't find how to improve it further; - Updates version from 12.9.0 to 12.10.0; - Dropped the documentation patch, as it didn't reflect reality; - Dropped the lxc driver patch. I didn't drop before because I thought it was open for discussion from others, and not decided yes what should be done with it; - Fixed the news documentation with the suggested text; Ben Grande (3): include: Introduce VIR_DOMAIN_EVENT_STOPPED_REBOOT detail drivers: Propagate stopped detail of reboot NEWS: Introduce VIR_DOMAIN_EVENT_STOPPED_REBOOT NEWS.rst | 6 ++++++ examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 1 + src/libxl/libxl_domain.c | 2 +- src/test/test_driver.c | 2 +- tools/virsh-domain-event.c | 3 ++- 6 files changed, 14 insertions(+), 3 deletions(-) -- Benjamin Grande
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 <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..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
Resolves: https://github.com/QubesOS/qubes-issues/issues/8196 Signed-off-by: Ben Grande <ben@invisiblethingslab.com> --- src/libxl/libxl_domain.c | 2 +- src/test/test_driver.c | 2 +- 2 files changed, 2 insertions(+), 2 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/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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 802f89190a..2fdac612e6 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,6 +33,12 @@ 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 detail + + A new ``VIR_DOMAIN_EVENT_STOPPED_REBOOT`` detail is now available for use + with the ``VIR_DOMAIN_EVENT_STOPPED`` lifecycle event. Drivers may use it + to indicate a domain has stopped as part of a reboot request. + * **Improvements** * **Bug fixes** -- Benjamin Grande
participants (1)
-
Ben Grande