qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/5] blockdev-mirror: Sanity check before mov


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v2 1/5] blockdev-mirror: Sanity check before moving target_bs AioContext
Date: Wed, 28 Sep 2016 18:37:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 27.09.2016 08:37, Fam Zheng wrote:
> Similar to blockdev-backup, if the target was already moved to a
> different AioContext, bad things can happen. This happens when the
> target belongs to a data plane device. It's a very unlikely case, but
> let's check it anyway.

You didn't implement it for blockdev-mirror, though, but for
drive-mirror (which I don't think needs this check).

Max

> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  blockdev.c | 35 ++++++++++++++++++++++++-----------
>  1 file changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 29c6561..a4960b9 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3281,6 +3281,21 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error 
> **errp)
>      return bdrv_named_nodes_list(errp);
>  }
>  
> +static void blockdev_set_aio_context(BlockDriverState *bs, AioContext *ctx,
> +                                     Error **errp)
> +{
> +    if (bdrv_get_aio_context(bs) != ctx) {
> +        if (!bdrv_has_blk(bs)) {
> +            /* The target BDS is not attached, we can safely move it to 
> another
> +             * AioContext. */
> +            bdrv_set_aio_context(bs, ctx);
> +        } else {
> +            error_setg(errp, "Target is attached to a different thread from "
> +                             "source.");
> +        }
> +    }
> +}
> +
>  void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error 
> **errp)
>  {
>      BlockDriverState *bs;
> @@ -3317,16 +3332,10 @@ void do_blockdev_backup(BlockdevBackup *backup, 
> BlockJobTxn *txn, Error **errp)
>          goto out;
>      }
>  
> -    if (bdrv_get_aio_context(target_bs) != aio_context) {
> -        if (!bdrv_has_blk(target_bs)) {
> -            /* The target BDS is not attached, we can safely move it to 
> another
> -             * AioContext. */
> -            bdrv_set_aio_context(target_bs, aio_context);
> -        } else {
> -            error_setg(errp, "Target is attached to a different thread from "
> -                             "source.");
> -            goto out;
> -        }
> +    blockdev_set_aio_context(target_bs, aio_context, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        goto out;
>      }
>      backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
>                   NULL, backup->compress, backup->on_source_error,
> @@ -3538,7 +3547,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
>          goto out;
>      }
>  
> -    bdrv_set_aio_context(target_bs, aio_context);
> +    blockdev_set_aio_context(target_bs, aio_context, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        goto out;
> +    }
>  
>      blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, 
> target_bs,
>                             arg->has_replaces, arg->replaces, arg->sync,
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]