[libvirt] [PATCH] virsh: Fix msg: blockjob is aborted from another client
Ján Tomko
jtomko at redhat.com
Thu Nov 13 13:58:30 UTC 2014
On 11/13/2014 02:32 PM, 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.
Is there a public bug for this issue?
> ---
> tools/virsh-domain.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 71 insertions(+), 3 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 8e743f1..025395f 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -1710,6 +1710,17 @@ static void vshCatchInt(int sig ATTRIBUTE_UNUSED,
> intCaught = 1;
> }
>
> +static void
> +vshBlockJobStatusHandler(virConnectPtr conn ATTRIBUTE_UNUSED,
> + virDomainPtr dom ATTRIBUTE_UNUSED,
> + const char *disk ATTRIBUTE_UNUSED,
> + int type ATTRIBUTE_UNUSED,
> + int status,
> + void *opaque)
> +{
> + *(int *) opaque = status;
> +}
> +
> /*
> * "blockcommit" command
> */
> @@ -1809,6 +1820,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) {
> @@ -1838,6 +1851,18 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
> return false;
> }
>
> + virConnectDomainEventGenericCallback cb =
> + VIR_DOMAIN_EVENT_CALLBACK(vshBlockJobStatusHandler);
> +
> + if ((cb_id = virConnectDomainEventRegisterAny(ctl->conn,
> + dom,
> + VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2,
I'd rather use EVENT_ID_BLOCK_JOB as it was introduced earlier and we only
care about status here.
> + cb,
> + &status,
> + NULL)) < 0) {
> + goto cleanup;
> + }
> +
The failure should be non-fatal, in case someone is creative enough to use
newest virsh to connect to old libvirtd that doesn't know the event yet.
Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141113/f931508e/attachment-0001.sig>
More information about the libvir-list
mailing list