From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: Akkarit Sangpetch <asangpet@andrew.cmu.edu>
Subject: [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file
Date: Fri, 17 Jul 2009 10:02:15 +0200 [thread overview]
Message-ID: <1247817735-14831-1-git-send-email-kwolf@redhat.com> (raw)
From: Akkarit Sangpetch <asangpet@andrew.cmu.edu>
Make 'qemu-img convert' copies unallocated parts of the source image
when -B option was not specified.
Signed-off-by: Akkarit Sangpetch <asangpet@andrew.cmu.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
Akkarit doesn't seem to repost with the patch corruption fixed, but we
need this fix anyway.
qemu-img.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index d806cfa..070fe2e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -747,14 +747,20 @@ static int img_convert(int argc, char **argv)
n = bs_offset + bs_sectors - sector_num;
if (strcmp(drv->format_name, "host_device")) {
- if (!bdrv_is_allocated(bs[bs_i], sector_num - bs_offset,
- n, &n1)) {
- sector_num += n1;
- continue;
+ /* If the output image is being created as a copy on write image,
+ assume that sectors which are unallocated in the input image
+ are present in both the output's and input's base images (no
+ need to copy them). */
+ if (out_baseimg) {
+ if (!bdrv_is_allocated(bs[bs_i], sector_num - bs_offset,
+ n, &n1)) {
+ sector_num += n1;
+ continue;
+ }
+ /* The next 'n1' sectors are allocated in the input image. Copy
+ only those as they may be followed by unallocated sectors. */
+ n = n1;
}
- /* The next 'n1' sectors are allocated in the input image. Copy
- only those as they may be followed by unallocated sectors. */
- n = n1;
} else {
n1 = n;
}
--
1.6.0.6
next reply other threads:[~2009-07-17 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 8:02 Kevin Wolf [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-07-07 16:57 [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file Akkarit Sangpetch
2009-07-10 13:32 ` Anthony Liguori
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=1247817735-14831-1-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=asangpet@andrew.cmu.edu \
--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).