[PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'

Peter Krempa posted 22 patches 4 years, 3 months ago
[PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
Posted by Peter Krempa 4 years, 3 months ago
The qemu driver didn't ever implement any meaningful handling for the
'preserve' action.

Forbid the flag in the qemu def validator and update the documentation
to be factual.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/formatdomain.rst    |  3 +--
 src/qemu/qemu_validate.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index fba4765e35..a894a51c00 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1747,8 +1747,7 @@ Each of these states allow for the same four possible actions.
    supported by the libxl hypervisor driver.)

 QEMU/KVM supports the ``on_poweroff`` and ``on_reboot`` events handling the
-``destroy`` and ``restart`` actions. The ``preserve`` action for an
-``on_reboot`` event is treated as a ``destroy``.
+``destroy`` and ``restart`` actions.

 The ``on_crash`` event supports these additional actions :since:`since 0.8.4` .

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 7bd8d8d9e7..d27c3b6c6c 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1079,6 +1079,16 @@ qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
         return -1;
     }

+    /* The qemu driver doesn't yet implement any meaningful handling for
+     * VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE */
+    if (onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE ||
+        onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE ||
+        onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("qemu driver doesn't support the 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'"));
+        return -1;
+    }
+
     return 0;
 }

-- 
2.31.1

Re: [PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
Posted by Christian Borntraeger 4 years, 3 months ago
On 24.08.21 16:44, Peter Krempa wrote:
> The qemu driver didn't ever implement any meaningful handling for the
> 'preserve' action.
> 
> Forbid the flag in the qemu def validator and update the documentation
> to be factual.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>

NACK. It is a perfectly sane usecase to have "preserve" on a crash. The qemu
will simply sit in that state and the user can then do virsh dump or similar.


> ---
>   docs/formatdomain.rst    |  3 +--
>   src/qemu/qemu_validate.c | 10 ++++++++++
>   2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index fba4765e35..a894a51c00 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -1747,8 +1747,7 @@ Each of these states allow for the same four possible actions.
>      supported by the libxl hypervisor driver.)
> 
>   QEMU/KVM supports the ``on_poweroff`` and ``on_reboot`` events handling the
> -``destroy`` and ``restart`` actions. The ``preserve`` action for an
> -``on_reboot`` event is treated as a ``destroy``.
> +``destroy`` and ``restart`` actions.
> 
>   The ``on_crash`` event supports these additional actions :since:`since 0.8.4` .
> 
> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> index 7bd8d8d9e7..d27c3b6c6c 100644
> --- a/src/qemu/qemu_validate.c
> +++ b/src/qemu/qemu_validate.c
> @@ -1079,6 +1079,16 @@ qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
>           return -1;
>       }
> 
> +    /* The qemu driver doesn't yet implement any meaningful handling for
> +     * VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE */
> +    if (onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE ||
> +        onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE ||
> +        onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("qemu driver doesn't support the 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'"));
> +        return -1;
> +    }
> +
>       return 0;
>   }
> 

Re: [PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
Posted by Christian Borntraeger 4 years, 3 months ago

On 15.09.21 11:45, Christian Borntraeger wrote:
> On 24.08.21 16:44, Peter Krempa wrote:
>> The qemu driver didn't ever implement any meaningful handling for the
>> 'preserve' action.
>>
>> Forbid the flag in the qemu def validator and update the documentation
>> to be factual.
>>
>> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> 
> NACK. It is a perfectly sane usecase to have "preserve" on a crash. The qemu
> will simply sit in that state and the user can then do virsh dump or similar.
> 

To make this statement stronger. I use this A LOT in real life to force libvirt
to leave the QEMU in that state to get dump and debug info.

Re: [PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
Posted by Daniel P. Berrangé 4 years, 3 months ago
On Wed, Sep 15, 2021 at 11:47:04AM +0200, Christian Borntraeger wrote:
> 
> 
> On 15.09.21 11:45, Christian Borntraeger wrote:
> > On 24.08.21 16:44, Peter Krempa wrote:
> > > The qemu driver didn't ever implement any meaningful handling for the
> > > 'preserve' action.
> > > 
> > > Forbid the flag in the qemu def validator and update the documentation
> > > to be factual.
> > > 
> > > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > 
> > NACK. It is a perfectly sane usecase to have "preserve" on a crash. The qemu
> > will simply sit in that state and the user can then do virsh dump or similar.
> > 
> 
> To make this statement stronger. I use this A LOT in real life to force libvirt
> to leave the QEMU in that state to get dump and debug info.

We probably just need to add a commentin libvirt source somewhere
relevant to the effect that "preserve" is the default behaviour
from QEMU so libvirt doesn't need todo anything extra.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [PATCH 07/22] qemu: Reject 'preserve' action for 'on_reboot'/'on_poweroff'/'on_crash'
Posted by Peter Krempa 4 years, 3 months ago
On Wed, Sep 15, 2021 at 10:57:23 +0100, Daniel P. Berrangé wrote:
> On Wed, Sep 15, 2021 at 11:47:04AM +0200, Christian Borntraeger wrote:
> > 
> > 
> > On 15.09.21 11:45, Christian Borntraeger wrote:
> > > On 24.08.21 16:44, Peter Krempa wrote:
> > > > The qemu driver didn't ever implement any meaningful handling for the
> > > > 'preserve' action.
> > > > 
> > > > Forbid the flag in the qemu def validator and update the documentation
> > > > to be factual.
> > > > 
> > > > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > > 
> > > NACK. It is a perfectly sane usecase to have "preserve" on a crash. The qemu
> > > will simply sit in that state and the user can then do virsh dump or similar.
> > > 
> > 
> > To make this statement stronger. I use this A LOT in real life to force libvirt
> > to leave the QEMU in that state to get dump and debug info.
> 
> We probably just need to add a commentin libvirt source somewhere
> relevant to the effect that "preserve" is the default behaviour
> from QEMU so libvirt doesn't need todo anything extra.

Hmm, yeah for 'onCrash' it actually might make sense. Unfortunately it
was totally broken for onReboot and onShutdown.

I'll remove the check for onCrash, but for the other two I'll leave it
in as it didn't work at all and I don't really care enough to implement
it.