qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 9/9] block: vhdx write support
Date: Tue, 30 Jul 2013 12:10:14 +0800	[thread overview]
Message-ID: <20130730041014.GC31918@T430s.nay.redhat.com> (raw)
In-Reply-To: <7afd1d43841f39d8445a6c9800d562e9cbea37f0.1374687002.git.jcody@redhat.com>

On Wed, 07/24 13:54, Jeff Cody wrote:
> This adds support for writing to VHDX image files, using coroutines.
> Writes into the BAT table goes through the VHDX log.  Currently, BAT
> table writes occur when expanding a dynamic VHDX file, and allocating a
> new BAT entry.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/vhdx.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 147 insertions(+), 2 deletions(-)
> 
> diff --git a/block/vhdx.c b/block/vhdx.c
> index a8dd6d7..791c6dc 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -831,7 +831,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags)
>          vhdx_update_headers(bs, s, false, NULL);
>      }
>  
> -    /* TODO: differencing files, write */
> +    /* TODO: differencing files */
>  
>      return 0;
>  fail:
> @@ -963,7 +963,45 @@ exit:
>      return ret;
>  }
>  
> +/*
> + * Allocate a new payload block at the end of the file.
> + *
> + * Allocation will happen at 1MB alignment inside the file
> + *
> + * Returns the file offset start of the new payload block
> + */
> +static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s,
> +                                    uint64_t *new_offset)
> +{
> +    *new_offset = bdrv_getlength(bs->file);
>  
> +    /* per the spec, the address for a block is in units of 1MB */
> +    if (*new_offset % (1024*1024)) {
> +        *new_offset = ((*new_offset >> 20) + 1) << 20;  /* round up to 1MB */

You can use ROUND_UP() macro here:

*new_offset = ROUND_UP(*new_offset, 1 << 20);

Fam

      reply	other threads:[~2013-07-30  4:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 17:54 [Qemu-devel] [PATCH 0/9] VHDX log replay and write support Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 1/9] block: vhdx - minor comments and typo correction Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 2/9] block: vhdx - add header update capability Jeff Cody
2013-07-26  6:49   ` Fam Zheng
2013-07-26 11:39     ` Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 3/9] block: vhdx code movement - VHDXMetadataEntries and BDRVVHDXState to header Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 4/9] block: vhdx - log support struct and defines Jeff Cody
2013-07-30  3:15   ` Fam Zheng
2013-07-30 13:42     ` Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 5/9] block: vhdx - break endian translation functions out Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 6/9] block: vhdx - update log guid in header, and first write tracker Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 7/9] block: vhdx - log parsing, replay, and flush support Jeff Cody
2013-07-30  3:48   ` Fam Zheng
2013-07-30 13:58     ` Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 8/9] block: vhdx - add log write support Jeff Cody
2013-07-30  3:57   ` Fam Zheng
2013-07-30 14:11     ` Jeff Cody
2013-07-24 17:54 ` [Qemu-devel] [PATCH 9/9] block: vhdx " Jeff Cody
2013-07-30  4:10   ` Fam Zheng [this message]

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=20130730041014.GC31918@T430s.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@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).