yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From dc37b3a1cd7c01dfccf9459a973694cee266957f Mon Sep 17 00:00:00 2001
9ae3a8
From: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Date: Sat, 11 Jan 2014 17:59:59 +0100
9ae3a8
Subject: [PATCH 09/22] fix double free the memslot in kvm_set_phys_mem
9ae3a8
9ae3a8
RH-Author: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Message-id: <1389463208-6278-10-git-send-email-lersek@redhat.com>
9ae3a8
Patchwork-id: 56622
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH 09/18] fix double free the memslot in kvm_set_phys_mem
9ae3a8
Bugzilla: 1032346
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
RH-Acked-by: Andrew Jones <drjones@redhat.com>
9ae3a8
9ae3a8
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
9ae3a8
9ae3a8
Luiz Capitulino reported that guest refused to boot and qemu
9ae3a8
complained with:
9ae3a8
kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument
9ae3a8
9ae3a8
It is caused by commit 235e8982ad that did double free for the memslot
9ae3a8
so that the second one raises the -EINVAL error
9ae3a8
9ae3a8
Fix it by reset memory size only if it is needed
9ae3a8
9ae3a8
Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
9ae3a8
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
9ae3a8
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
9ae3a8
(cherry picked from commit 651eb0f41b793021f7de672de78892def5819fb9)
9ae3a8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
---
9ae3a8
 kvm-all.c | 3 ++-
9ae3a8
 1 file changed, 2 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 kvm-all.c |    3 ++-
9ae3a8
 1 files changed, 2 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/kvm-all.c b/kvm-all.c
9ae3a8
index 42c71b9..16e4f65 100644
9ae3a8
--- a/kvm-all.c
9ae3a8
+++ b/kvm-all.c
9ae3a8
@@ -208,7 +208,8 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
9ae3a8
     if (s->migration_log) {
9ae3a8
         mem.flags |= KVM_MEM_LOG_DIRTY_PAGES;
9ae3a8
     }
9ae3a8
-    if (mem.flags & KVM_MEM_READONLY) {
9ae3a8
+
9ae3a8
+    if (slot->memory_size && mem.flags & KVM_MEM_READONLY) {
9ae3a8
         /* Set the slot size to 0 before setting the slot to the desired
9ae3a8
          * value. This is needed based on KVM commit 75d61fbc. */
9ae3a8
         mem.memory_size = 0;
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8