Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 3160499aacb81f6735941eb4c372d87a > files > 585

kvm-83-164.el5_5.30.src.rpm

From c14bc48e209191a6794aeb988af7e2eec0119ca9 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Mon, 25 Jan 2010 10:07:38 -0200
Subject: [PATCH 1/5] qemu-img: Fix qemu-img with backing file

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1264414058-15608-1-git-send-email-kwolf@redhat.com>
Patchwork-id: 6564
O-Subject: [RHEL-5.5 KVM PATCH] qemu-img: Fix qemu-img with backing file
Bugzilla: 558195
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Avi Kivity <avi@redhat.com>

From: Akkarit Sangpetch <asangpet@andrew.cmu.edu>

Bugzilla: 558195
Upstream commit: d032044fb97d525ae93fb4c96713a5c467044c17

Make 'qemu-img convert' copy 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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu/qemu-img.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/qemu-img.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/qemu/qemu-img.c b/qemu/qemu-img.c
index c2d4f72..d657f5d 100644
--- a/qemu/qemu-img.c
+++ b/qemu/qemu-img.c
@@ -697,14 +697,20 @@ static int img_convert(int argc, char **argv)
                 n = bs_offset + bs_sectors - sector_num;
 
             if (drv != &bdrv_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.3.rc4.29.g8146