[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv2] virsh: Fix msg: blockjob is aborted from another client



On 11/19/14 14:54, Erik Skultety wrote:
> When a block{pull, copy, commit} is aborted via keyboard interrupt,
> the job is properly canceled followed by proper error message.
> However, when the job receives an abort from another client connected
> to the same domain, the error message incorrectly indicates that
> a blockjob has been finished successfully, though the abort request
> took effect. This patch introduces a new blockjob abort handler, which
> is registered when the client calls block{copy,commit,pull} routine,
> providing its caller the status of the finished blockjob.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1135442
> ---
>  tools/virsh-domain.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 62 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index a7e9151..90960e9 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c

> @@ -1808,6 +1819,8 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
>      const char *path = NULL;
>      bool quit = false;
>      int abort_flags = 0;
> +    int status = -1;
> +    int cb_id = -1;
>  
>      blocking |= vshCommandOptBool(cmd, "timeout") || pivot || finish;
>      if (blocking) {
> @@ -1837,6 +1850,16 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
>          return false;
>      }
>  
> +    virConnectDomainEventGenericCallback cb =
> +        VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
> +
> +    cb_id = virConnectDomainEventRegisterAny(ctl->conn,
> +                                             dom,
> +                                             VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
> +                                             cb,
> +                                             &status,
> +                                             NULL);

You should call vshResetLibvirtError in case you want to ignore failure
of registration of the callback.

> +
>      if (!blockJobImpl(ctl, cmd, VSH_CMD_BLOCK_JOB_COMMIT, &dom))
>          goto cleanup;
>  

> @@ -1920,6 +1946,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
>          virDomainFree(dom);
>      if (blocking)
>          sigaction(SIGINT, &old_sig_action, NULL);
> +    virConnectDomainEventDeregisterAny(ctl->conn, cb_id);

And deregister it only if the callback id isn't -1 as it will again
overwrite the saved error.

>      return ret;
>  }
>  

Otherwise looks good.

Peter


Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]