qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH v3 3/9] qcow2: Implement copy offloading


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [PATCH v3 3/9] qcow2: Implement copy offloading
Date: Thu, 10 May 2018 10:25:50 +0100
User-agent: Mutt/1.9.3 (2018-01-21)

On Wed, May 09, 2018 at 10:58:09PM +0800, Fam Zheng wrote:
> +static int qcow2_co_copy_range_from(BlockDriverState *bs,
> +                                    BdrvChild *src, uint64_t src_offset,
> +                                    BdrvChild *dst, uint64_t dst_offset,
> +                                    uint64_t bytes, BdrvRequestFlags flags)
> +{
> +    BDRVQcow2State *s = bs->opaque;
> +    int offset_in_cluster;
> +    int ret;
> +    unsigned int cur_bytes; /* number of bytes in current iteration */
> +    uint64_t cluster_offset = 0;
> +    BdrvChild *child = NULL;
> +
> +    assert(!bs->encrypted);
> +    qemu_co_mutex_lock(&s->lock);
> +
> +    while (bytes != 0) {
> +
> +        /* prepare next request */
> +        cur_bytes = MIN(bytes, INT_MAX);
> +
> +        ret = qcow2_get_cluster_offset(bs, src_offset, &cur_bytes, 
> &cluster_offset);
> +        if (ret < 0) {
> +            goto out;
> +        }
> +
> +        offset_in_cluster = offset_into_cluster(s, src_offset);
> +
> +        switch (ret) {
> +        case QCOW2_CLUSTER_UNALLOCATED:
> +            if (bs->backing) {
> +                child = bs->backing;
> +            } else {
> +                flags |= BDRV_REQ_ZERO_WRITE;
> +            }
> +            break;

Do we need a special case if the backing file is shorter than this
image?

Attachment: signature.asc
Description: PGP signature


reply via email to

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