thebeanogamer / rpms / qemu-kvm

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