On Wed, Apr 17, 2024 at 13:58:06 +0800, Sun Feng wrote: > For abnormal shutoff reasons, we can start guest again with qemu hooks. Beware that: A hook script must not call back into libvirt, as the libvirt daemon is already waiting for the script to exit. A deadlock is likely to occur. https://libvirt.org/hooks.html#calling-libvirt-functions-from-within-a-hook-script Preferrably summarize what the patch is doing or suggest something that is not strongly discouraged by the docs. > Signed-off-by: Sun Feng <loyou85@xxxxxxxxx> > --- > docs/hooks.rst | 3 ++- > src/qemu/qemu_process.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/docs/hooks.rst b/docs/hooks.rst > index 1dbc492bd4..45856e4ca4 100644 > --- a/docs/hooks.rst > +++ b/docs/hooks.rst > @@ -204,7 +204,8 @@ operation. There is no specific operation to indicate a "restart" is occurring. > > - When a QEMU guest is stopped, the qemu hook script is called in two > locations, to match the startup. First, :since:`since 0.8.0`, the hook is > - called before libvirt restores any labels: > + called before libvirt restores any labels, :since:`since 9.10.0`, shutoff > + reason is delivered with **extra argument**: Next release is going to be 10.3.0 > > :: > > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index e4bcb628cf..c42f5c9139 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c > @@ -8564,7 +8564,8 @@ void qemuProcessStop(virQEMUDriver *driver, > /* we can't stop the operation even if the script raised an error */ > ignore_value(virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name, > VIR_HOOK_QEMU_OP_STOPPED, VIR_HOOK_SUBOP_END, > - NULL, xml, NULL)); > + virDomainShutoffReasonTypeToString(reason), > + xml, NULL)); To be honest I'm not exactly sold that this is needed as the reason for this hook's existence is to simply clear up any resources that would be set up by the start hook, thus it's usually irrelevant why that happened. In your example you need to setup the hook so that it spawns off a separate process and terminates thus you can also query the shutdown reason from libvirt in that call too. Said that I'm not strongly against it, I'm just pointing out that I don't really see a good reason based on the fact that the hooks must not call back into libvirt. I'll let others chime in with their opinion. _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx