cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From f50d8d218780ea455bb7dc6d7ccdd0c5b931f4a8 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Tue, 5 Nov 2013 14:09:17 +0100
218e99
Subject: [PATCH 64/87] block: fix backing file overriding
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383660558-32096-24-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55402
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 23/24] block: fix backing file overriding
218e99
Bugzilla: 978402
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
218e99
From: Fam Zheng <famz@redhat.com>
218e99
218e99
Providing backing.file.filename doesn't override backing file as expected:
218e99
218e99
    $ x86_64-softmmu/qemu-system-x86_64 -drive \
218e99
        file=/tmp/child.qcow2,backing.file.filename=/tmp/fake.qcow2
218e99
218e99
    qemu-system-x86_64: -drive \
218e99
        file=/tmp/child.qcow2,backing.file.filename=/tmp/fake.qcow2: could not
218e99
        open disk image /tmp/child.qcow2: Can't specify 'file' and 'filename'
218e99
        options at the same time
218e99
218e99
With
218e99
218e99
    $ qemu-img info /tmp/child.qcow2
218e99
    image: /tmp/child.qcow2
218e99
    file format: qcow2
218e99
    virtual size: 1.0G (1073741824 bytes)
218e99
    disk size: 196K
218e99
    cluster_size: 65536
218e99
    backing file: /tmp/fake.qcow2
218e99
218e99
This fixes it by calling bdrv_get_full_backing_filename only if
218e99
backing.file.filename is not provided. Also save the backing file name
218e99
to bs->backing_file so the information is correct with HMP "info block".
218e99
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit dbecebddfa4932d1c83915bcb9b5ba5984eb91be)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 block.c | 7 +++++--
218e99
 1 file changed, 5 insertions(+), 2 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block.c |    7 +++++--
218e99
 1 files changed, 5 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/block.c b/block.c
218e99
index d11661a..01c11ee 100644
218e99
--- a/block.c
218e99
+++ b/block.c
218e99
@@ -956,11 +956,12 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
218e99
     } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {
218e99
         QDECREF(options);
218e99
         return 0;
218e99
+    } else {
218e99
+        bdrv_get_full_backing_filename(bs, backing_filename,
218e99
+                                       sizeof(backing_filename));
218e99
     }
218e99
 
218e99
     bs->backing_hd = bdrv_new("");
218e99
-    bdrv_get_full_backing_filename(bs, backing_filename,
218e99
-                                   sizeof(backing_filename));
218e99
 
218e99
     if (bs->backing_format[0] != '\0') {
218e99
         back_drv = bdrv_find_format(bs->backing_format);
218e99
@@ -972,6 +973,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
218e99
     ret = bdrv_open(bs->backing_hd,
218e99
                     *backing_filename ? backing_filename : NULL, options,
218e99
                     back_flags, back_drv, &local_err);
218e99
+    pstrcpy(bs->backing_file, sizeof(bs->backing_file),
218e99
+            bs->backing_hd->file->filename);
218e99
     if (ret < 0) {
218e99
         bdrv_delete(bs->backing_hd);
218e99
         bs->backing_hd = NULL;
218e99
-- 
218e99
1.7.1
218e99