Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 282

kvm-83-270.el5_11.src.rpm

From 34f656348666fc913fdd2d31f0e7b410d5ff57cb Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 7 Oct 2010 16:10:51 -0300
Subject: [PATCH 2/2] block: Fix image re-open in bdrv_commit

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1286467851-16118-1-git-send-email-kwolf@redhat.com>
Patchwork-id: 12455
O-Subject: [RHEL-5.6 KVM PATCH] block: Fix image re-open in bdrv_commit
Bugzilla: 640949
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
RH-Acked-by: Christoph Hellwig <chellwig@redhat.com>

Bugzilla: 640949
Upstream commit: ee1811965fd15e0b41f8d508b951a8ab826ae3a7

Arguably we should re-open the backing file with the backing file format and
not with the format of the snapshot image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu/block.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/block.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/qemu/block.c b/qemu/block.c
index 712150c..58b8c83 100644
--- a/qemu/block.c
+++ b/qemu/block.c
@@ -614,6 +614,7 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res)
 int bdrv_commit(BlockDriverState *bs)
 {
     BlockDriver *drv = bs->drv;
+    BlockDriver *backing_drv;
     int64_t i, total_sectors;
     int n, j;
     int ro, open_flags;
@@ -633,6 +634,7 @@ int bdrv_commit(BlockDriverState *bs)
         return -EACCES;
     }
 
+    backing_drv = bs->backing_hd->drv;
     ro = bs->backing_hd->read_only;
     strncpy(filename, bs->backing_hd->filename, sizeof(filename));
     open_flags =  bs->backing_hd->open_flags;
@@ -642,12 +644,14 @@ int bdrv_commit(BlockDriverState *bs)
         bdrv_delete(bs->backing_hd);
         bs->backing_hd = NULL;
         bs_rw = bdrv_new("");
-        rw_ret = bdrv_open2(bs_rw, filename, open_flags | BDRV_O_RDWR, drv);
+        rw_ret = bdrv_open2(bs_rw, filename, open_flags | BDRV_O_RDWR,
+            backing_drv);
         if (rw_ret < 0) {
             bdrv_delete(bs_rw);
             /* try to re-open read-only */
             bs_ro = bdrv_new("");
-            ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv);
+            ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR,
+                backing_drv);
             if (ret < 0) {
                 bdrv_delete(bs_ro);
                 /* drive not functional anymore */
@@ -690,7 +694,8 @@ ro_cleanup:
         bdrv_delete(bs->backing_hd);
         bs->backing_hd = NULL;
         bs_ro = bdrv_new("");
-        ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv);
+        ret = bdrv_open2(bs_ro, filename, open_flags & ~BDRV_O_RDWR,
+            backing_drv);
         if (ret < 0) {
             bdrv_delete(bs_ro);
             /* drive not functional anymore */
-- 
1.6.5.5