qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Devin Nakamura <devin122@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 6/6] qed: add bdrv_qed_copy_header()
Date: Tue, 20 Sep 2011 12:14:07 +0200	[thread overview]
Message-ID: <4E78676F.7040606@redhat.com> (raw)
In-Reply-To: <1315839554-14357-1-git-send-email-devin122@gmail.com>

Am 12.09.2011 16:59, schrieb Devin Nakamura:
> Signed-off-by: Devin Nakamura <devin122@gmail.com>
> ---
>  block/qed.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/block/qed.c b/block/qed.c
> index 341cf9d..caecdff 100644
> --- a/block/qed.c
> +++ b/block/qed.c
> @@ -1586,6 +1586,20 @@ static int bdrv_qed_map(BlockDriverState *bs, uint64_t guest_offset,
>      return 0;
>  }
>  
> +static int bdrv_qed_copy_header(BlockDriverState *bs, char* filename)
> +{
> +    BlockDriverState *backup;
> +    uint8_t buffer[512];
> +    bdrv_create_file(filename, NULL);
> +    bdrv_file_open(&backup, filename, BDRV_O_RDWR);
> +    bdrv_read(bs->file, 0, buffer, 1); /*TODO: check return code*/
> +    bdrv_write(backup, 0, buffer, 1); /*TODO: check return code*/

Come on, checking return values isn't much more work than adding a TODO
comment.

> +    bdrv_close(backup);
> +
> +    qed_write_header_sync(bs->opaque);
> +    return 0;
> +}

This is probably right, but it makes me wonder if we are sure that QED
never tries to write out the header before bdrv_qed_copy_header() is
called? In that case we would have destroyed the original format before
completing the conversion.

I would feel more comfortable if BDRVQEDState had a field header_offset
that would be set to a temporary location by
bdrv_qed_open_conversion_target and reset to 0 by bdrv_qed_copy_header.

Kevin

      reply	other threads:[~2011-09-20 10:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-12 14:59 [Qemu-devel] [PATCH 6/6] qed: add bdrv_qed_copy_header() Devin Nakamura
2011-09-20 10:14 ` Kevin Wolf [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=4E78676F.7040606@redhat.com \
    --to=kwolf@redhat.com \
    --cc=devin122@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).