yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From 3ab144fe22a867a0ffcce396302b62b0f2ac4c29 Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Fri, 1 Nov 2013 14:23:16 +0100
218e99
Subject: [PATCH 28/81] qcow2: Unset zero_beyond_eof in save_vmstate
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383315797-30938-3-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55217
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 2/3] qcow2: Unset zero_beyond_eof in save_vmstate
218e99
Bugzilla: 1025740
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
218e99
218e99
BZ: 1025740
218e99
218e99
Saving the VM state is done using bdrv_pwrite. This function may perform
218e99
a read-modify-write, which in this case results in data being read from
218e99
beyond the end of the virtual disk. Since we are actually trying to
218e99
access an area which is not a part of the virtual disk, zero_beyond_eof
218e99
has to be set to false before performing the partial write, otherwise
218e99
the VM state may become corrupted.
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 6e13610aa454beba52944e8df6d93158d68ab911)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 block/qcow2.c | 3 +++
218e99
 1 file changed, 3 insertions(+)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/qcow2.c |    3 +++
218e99
 1 files changed, 3 insertions(+), 0 deletions(-)
218e99
218e99
diff --git a/block/qcow2.c b/block/qcow2.c
218e99
index f4adf35..c2728c9 100644
218e99
--- a/block/qcow2.c
218e99
+++ b/block/qcow2.c
218e99
@@ -1718,12 +1718,15 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
218e99
     BDRVQcowState *s = bs->opaque;
218e99
     int64_t total_sectors = bs->total_sectors;
218e99
     int growable = bs->growable;
218e99
+    bool zero_beyond_eof = bs->zero_beyond_eof;
218e99
     int ret;
218e99
 
218e99
     BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
218e99
     bs->growable = 1;
218e99
+    bs->zero_beyond_eof = false;
218e99
     ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
218e99
     bs->growable = growable;
218e99
+    bs->zero_beyond_eof = zero_beyond_eof;
218e99
 
218e99
     /* bdrv_co_do_writev will have increased the total_sectors value to include
218e99
      * the VM state - the VM state is however not an actual part of the block
218e99
-- 
218e99
1.7.1
218e99