[libvirt] [PATCH] qemu: Emit event if save fails

Eric Blake eblake at redhat.com
Tue Nov 6 17:07:58 UTC 2012


On 11/05/2012 08:05 AM, Michal Privoznik wrote:
> When we are doing a (managed-) save of a domain, we stop its processors
> firstly. And if the process of saving fails for some reason we try to
> wake them up again. However, if this fails, an event should be emitted
> so mgmt application can decide what to do.
> ---
> 
> I am not completely sure about combination of event and
> event detail, maybe we need to invent a new combination.
> Suggestions?  VIR_DOMAIN_EVENT_STOPPED_FAILED means an
> hypervisor error which may fit when 'cont' fails.
> 
>  src/qemu/qemu_driver.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 978af57..e1c6067 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2990,8 +2990,12 @@ endjob:
>                  rc = qemuProcessStartCPUs(driver, vm, dom->conn,
>                                            VIR_DOMAIN_RUNNING_SAVE_CANCELED,
>                                            QEMU_ASYNC_JOB_SAVE);
> -                if (rc < 0)
> +                if (rc < 0) {
>                      VIR_WARN("Unable to resume guest CPUs after save failure");
> +                    event = virDomainEventNewFromObj(vm,

Memory leak - event might already be non-NULL, but you are discarding it
by using your new event.

> +                                                     VIR_DOMAIN_EVENT_STOPPED,

Hmm, VIR_DOMAIN_EVENT_STOPPED seems wrong - if we failed, then the qemu
process still exists, and we are paused (VIR_DOMAIN_EVENT_SUSPENDED),
not stopped.

> +                                                     VIR_DOMAIN_EVENT_STOPPED_FAILED);

I think I would add a new category in libvirt.h.in; maybe
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR /* suspended after failure during
libvirt API call */.  None of the existing VIR_DOMAIN_EVENT_SUSPENDED_*
reasons seem to fit.  We may have other places in qemu_driver.c that
should also use this new error (that is, we have several commands that
temporarily pause the guest to perform an action, including Peter's
recent work on external snapshots, and where we might leave the guest
suspended on error).

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121106/b7159230/attachment-0001.sig>


More information about the libvir-list mailing list