qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	imain@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com
Subject: Re: [Qemu-devel] [PATCH v2 1/3] block: add basic backup support to block driver
Date: Thu, 30 May 2013 11:37:25 +0800	[thread overview]
Message-ID: <20130530033725.GA19726@localhost.nay.redhat.com> (raw)
In-Reply-To: <1367221335-22777-2-git-send-email-stefanha@redhat.com>

On Mon, 04/29 09:42, Stefan Hajnoczi wrote:
> +
> +static void coroutine_fn backup_run(void *opaque)
> +{
> +    BackupBlockJob *job = opaque;
> +    BlockDriverState *bs = job->common.bs;
> +    assert(bs);
> +
> +    int64_t start, end;
> +
> +    start = 0;
> +    end = DIV_ROUND_UP(bdrv_getlength(bs) / BDRV_SECTOR_SIZE,
> +                       BACKUP_BLOCKS_PER_CLUSTER);
> +
> +    job->bitmap = hbitmap_alloc(end, 0);
> +
> +    DPRINTF("backup_run start %s %" PRId64 " %" PRId64 "\n",
> +            bdrv_get_device_name(bs), start, end);
> +
> +    int ret = 0;
> +
> +    for (; start < end; start++) {
> +        if (block_job_is_cancelled(&job->common)) {
> +            ret = -1;
> +            break;
> +        }
> +
> +        /* we need to yield so that qemu_aio_flush() returns.
> +         * (without, VM does not reboot)
> +         */
> +        if (job->common.speed) {
> +            uint64_t delay_ns = ratelimit_calculate_delay(
> +                &job->limit, job->sectors_read);
> +            job->sectors_read = 0;
> +            block_job_sleep_ns(&job->common, rt_clock, delay_ns);
> +        } else {
> +            block_job_sleep_ns(&job->common, rt_clock, 0);
> +        }
> +
> +        if (block_job_is_cancelled(&job->common)) {
> +            ret = -1;
> +            break;
> +        }
> +
> +        if (hbitmap_get(job->bitmap, start)) {
> +            continue; /* already copied */
> +        }
> +
> +        DPRINTF("backup_run loop C%" PRId64 "\n", start);
> +
> +        /**
> +         * This triggers a cluster copy
> +         * Note: avoid direct call to brdv_co_backup_cow, because
> +         * this does not call tracked_request_begin()
> +         */
> +        ret = bdrv_co_backup(bs, start*BACKUP_BLOCKS_PER_CLUSTER, 1);
> +        if (ret < 0) {
> +            break;
> +        }
> +        /* Publish progress */
> +        job->common.offset += BACKUP_CLUSTER_SIZE;
> +    }
> +
> +    /* wait until pending backup_do_cow()calls have completed */
> +    qemu_co_rwlock_wrlock(&job->rwlock);
> +    qemu_co_rwlock_unlock(&job->rwlock);
> +
> +    hbitmap_free(job->bitmap);
> +
> +    bdrv_delete(job->target);
> +
> +    DPRINTF("backup_run complete %d\n", ret);
> +    block_job_completed(&job->common, ret);
> +}

What will ret value be when the source block is not aligned to cluster
size?

Fam

  parent reply	other threads:[~2013-05-30  3:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29  7:42 [Qemu-devel] [PATCH v2 0/3] block: block-backup live backup command Stefan Hajnoczi
2013-04-29  7:42 ` [Qemu-devel] [PATCH v2 1/3] block: add basic backup support to block driver Stefan Hajnoczi
2013-05-08 12:39   ` Kevin Wolf
2013-05-08 15:43     ` Paolo Bonzini
2013-05-14  8:51     ` Stefan Hajnoczi
2013-05-14 13:24     ` Stefan Hajnoczi
2013-05-14 13:43       ` Kevin Wolf
2013-05-14 15:12         ` Stefan Hajnoczi
2013-05-30  3:37   ` Fam Zheng [this message]
2013-05-30 12:27     ` Stefan Hajnoczi
2013-04-29  7:42 ` [Qemu-devel] [PATCH v2 2/3] block: add block-backup QMP command Stefan Hajnoczi
2013-05-08 12:49   ` Kevin Wolf
2013-05-11  3:34     ` Eric Blake
2013-05-11  8:02       ` Paolo Bonzini
2013-05-13  8:23       ` Kevin Wolf
2013-05-14  8:44     ` Stefan Hajnoczi
2013-05-11  4:02   ` Eric Blake
2013-05-13  8:28     ` Kevin Wolf
2013-05-13 12:56       ` Eric Blake
2013-05-13 13:09         ` Kevin Wolf
2013-05-13 13:18           ` Luiz Capitulino
2013-05-13 14:14             ` Eric Blake
2013-05-13 14:27               ` Kevin Wolf
2013-05-13 14:50                 ` Eric Blake
2013-05-14  2:18                   ` Wenchao Xia
2013-05-14  8:48     ` Stefan Hajnoczi
2013-04-29  7:42 ` [Qemu-devel] [PATCH v2 3/3] qemu-iotests: add 054 block-backup test case Stefan Hajnoczi

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=20130530033725.GA19726@localhost.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=dietmar@proxmox.com \
    --cc=imain@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xiawenc@linux.vnet.ibm.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).