[libvirt] [PATCHv2 2/2] qemu: emit 'defined' event after reverted to snapshot

John Ferlan jferlan at redhat.com
Wed Dec 16 12:21:40 UTC 2015



On 12/16/2015 04:09 AM, Dmitry Andreev wrote:
> If config file was changed VIR_DOMAIN_EVENT_DEFINED should be emitted
> ---
>  src/qemu/qemu_driver.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 

I liked v1 better with a tweak or two

> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 783a7cd..1474eaa 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -15512,7 +15512,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
>                                               VIR_DOMAIN_EVENT_STARTED,
>                                               detail);
>              if (rc < 0)
> -                goto endjob;
> +                goto defined;
>          }
>  
>          /* Touch up domain state.  */
> @@ -15534,7 +15534,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
>              if (!virDomainObjIsActive(vm)) {
>                  virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                                 _("guest unexpectedly quit"));
> -                goto endjob;
> +                goto defined;

There's done more goto endjob after here which would seemingly skip the
defined event.

There's also another "if (config)" in the SHUTDOWN, SHUTOFF, CRASHED
case that would be missed due to a goto cleanup

I can fiddle with v1 slightly and have it do the right thing.

John
>              }
>              rc = qemuProcessStartCPUs(driver, vm, snapshot->domain->conn,
>                                        VIR_DOMAIN_RUNNING_FROM_SNAPSHOT,
> @@ -15636,6 +15636,15 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
>  
>      ret = 0;
>  
> + defined:
> +    if (config) {
> +        virObjectEventPtr define_event;
> +        define_event = virDomainEventLifecycleNewFromObj(vm,
> +                                    VIR_DOMAIN_EVENT_DEFINED,
> +                                    VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT);
> +        qemuDomainEventQueue(driver, define_event);
> +    }
> +
>   endjob:
>      qemuProcessEndJob(driver, vm);
>  
> 




More information about the libvir-list mailing list