Sophie

Sophie

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

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

From ff03a04c6420826e643b0347544b33eb2bac3c5b Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 17 Dec 2009 14:32:42 -0200
Subject: [PATCH 1/5] block: Introduce BDRV_O_NO_BACKING

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1261060364-22778-2-git-send-email-kwolf@redhat.com>
Patchwork-id: 5785
O-Subject: [RHEL-5.5 KVM PATCH v3 1/3] block: Introduce BDRV_O_NO_BACKING
Bugzilla: 530134
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>

Bugzilla: 530134
Upstream status: Submitted

If an image references a backing file that doesn't exist, qemu-img info fails
to open this image. Exactly in this case the info would be valuable, though:
the user might want to find out which file is missing.

This patch introduces a BDRV_O_NO_BACKING flag to ignore the backing file when
opening the image. qemu-img info is the first user and provides info now even
if the backing file is invalid.

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

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

diff --git a/qemu/block.c b/qemu/block.c
index 490fb95..3255f39 100644
--- a/qemu/block.c
+++ b/qemu/block.c
@@ -492,7 +492,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
         unlink(filename);
     }
 #endif
-    if (bs->backing_file[0] != '\0') {
+    if ((flags & BDRV_O_NO_BACKING) == 0 && bs->backing_file[0] != '\0') {
         /* if there is a backing file, use it */
         BlockDriver *back_drv = NULL;
         bs->backing_hd = bdrv_new("");
@@ -1250,7 +1250,7 @@ void bdrv_info_stats (void)
 void bdrv_get_backing_filename(BlockDriverState *bs,
                                char *filename, int filename_size)
 {
-    if (!bs->backing_hd) {
+    if (!bs->backing_file) {
         pstrcpy(filename, filename_size, "");
     } else {
         pstrcpy(filename, filename_size, bs->backing_file);
diff --git a/qemu/block.h b/qemu/block.h
index 578d003..1132d6d 100644
--- a/qemu/block.h
+++ b/qemu/block.h
@@ -47,6 +47,7 @@ typedef struct QEMUSnapshotInfo {
 #define BDRV_O_NOCACHE     0x0020 /* do not use the host page cache */
 #define BDRV_O_CACHE_WB    0x0040 /* use write-back caching */
 #define BDRV_O_CACHE_DEF   0x0080 /* use default caching */
+#define BDRV_O_NO_BACKING  0x0100 /* don't open the backing file */
 
 #define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF)
 
diff --git a/qemu/qemu-img.c b/qemu/qemu-img.c
index e86cb88..58abdfb 100644
--- a/qemu/qemu-img.c
+++ b/qemu/qemu-img.c
@@ -783,7 +783,7 @@ static int img_info(int argc, char **argv)
     } else {
         drv = NULL;
     }
-    if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) {
+    if (bdrv_open2(bs, filename, BRDV_O_FLAGS | BDRV_O_NO_BACKING, drv) < 0) {
         error("Could not open '%s'", filename);
     }
     bdrv_get_format(bs, fmt_name, sizeof(fmt_name));
-- 
1.6.3.rc4.29.g8146