qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file
@ 2009-07-07 16:57 Akkarit Sangpetch
  2009-07-10 13:32 ` Anthony Liguori
  0 siblings, 1 reply; 3+ messages in thread
From: Akkarit Sangpetch @ 2009-07-07 16:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, asangpet

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>
---
  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.2.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file
  2009-07-07 16:57 Akkarit Sangpetch
@ 2009-07-10 13:32 ` Anthony Liguori
  0 siblings, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2009-07-10 13:32 UTC (permalink / raw)
  To: Akkarit Sangpetch; +Cc: kwolf, qemu-devel

Akkarit Sangpetch wrote:
> Make 'qemu-img convert' copies unallocated parts of the source image 
> when -B option was not specified.

git-am thinks this patch is corrupt. I suspect your mailer munged something.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file
@ 2009-07-17  8:02 Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2009-07-17  8:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Akkarit Sangpetch

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-17  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-17  8:02 [Qemu-devel] [PATCH] qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2009-07-07 16:57 Akkarit Sangpetch
2009-07-10 13:32 ` Anthony Liguori

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).