qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	mreitz@redhat.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/3] qmp: Add command 'blockdev-backup'
Date: Wed, 19 Nov 2014 16:23:16 +0000	[thread overview]
Message-ID: <20141119162316.GA15177@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1415156231-6319-2-git-send-email-famz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1774 bytes --]

On Wed, Nov 05, 2014 at 10:57:09AM +0800, Fam Zheng wrote:
> +void qmp_blockdev_backup(const char *device, const char *target,
> +                         enum MirrorSyncMode sync,
> +                         bool has_speed, int64_t speed,
> +                         bool has_on_source_error,
> +                         BlockdevOnError on_source_error,
> +                         bool has_on_target_error,
> +                         BlockdevOnError on_target_error,
> +                         Error **errp)
> +{
> +    BlockDriverState *bs;
> +    BlockDriverState *target_bs;
> +    Error *local_err = NULL;
> +
> +    if (!has_speed) {
> +        speed = 0;
> +    }
> +    if (!has_on_source_error) {
> +        on_source_error = BLOCKDEV_ON_ERROR_REPORT;
> +    }
> +    if (!has_on_target_error) {
> +        on_target_error = BLOCKDEV_ON_ERROR_REPORT;
> +    }
> +
> +    bs = bdrv_find(device);
> +    if (!bs) {
> +        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> +        return;
> +    }
> +
> +    target_bs = bdrv_find(target);
> +    if (!target_bs) {
> +        error_set(errp, QERR_DEVICE_NOT_FOUND, target);
> +        return;
> +    }
> +
> +    bdrv_ref(target_bs);
> +    backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error,
> +                 block_job_cb, bs, &local_err);
> +    if (local_err != NULL) {
> +        bdrv_unref(target_bs);
> +        error_propagate(errp, local_err);
> +    }
> +}

Please make sure to acquire AioContext so that this is safe with
dataplane.

Here the tricky thing is that bs and target_bs must have the same
AioContext.  The easiest thing is to refuse if their AioContexts are not
identical, but that puts the onus on the user to put the
BlockDriverStates into the same AioContext.

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-11-19 16:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05  2:57 [Qemu-devel] [PATCH v3 0/3] qmp: Add "blockdev-backup" Fam Zheng
2014-11-05  2:57 ` [Qemu-devel] [PATCH v3 1/3] qmp: Add command 'blockdev-backup' Fam Zheng
2014-11-19 16:23   ` Stefan Hajnoczi [this message]
2014-12-17  9:36   ` Markus Armbruster
2014-12-17 10:41     ` Fam Zheng
2014-12-19  8:20       ` Markus Armbruster
2014-12-23  2:10         ` Fam Zheng
2014-11-05  2:57 ` [Qemu-devel] [PATCH v3 2/3] block: Add blockdev-backup to transaction Fam Zheng
2014-12-17  9:40   ` Markus Armbruster
2014-12-17 10:44     ` Fam Zheng
2014-11-05  2:57 ` [Qemu-devel] [PATCH v3 3/3] qemu-iotests: Test blockdev-backup in 055 Fam Zheng
2014-12-17 10:41   ` Markus Armbruster
2014-12-17 10:44 ` [Qemu-devel] [PATCH v3 0/3] qmp: Add "blockdev-backup" Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141119162316.GA15177@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).