Skip to content
Snippets Groups Projects
Commit 651eb0f4 authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Anthony Liguori
Browse files

fix double free the memslot in kvm_set_phys_mem


Luiz Capitulino reported that guest refused to boot and qemu
complained with:
kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument

It is caused by commit 235e8982 that did double free for the memslot
so that the second one raises the -EINVAL error

Fix it by reset memory size only if it is needed

Reported-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 25b48338
No related branches found
No related tags found
No related merge requests found
......@@ -206,7 +206,8 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
if (s->migration_log) {
mem.flags |= KVM_MEM_LOG_DIRTY_PAGES;
}
if (mem.flags & KVM_MEM_READONLY) {
if (slot->memory_size && mem.flags & KVM_MEM_READONLY) {
/* Set the slot size to 0 before setting the slot to the desired
* value. This is needed based on KVM commit 75d61fbc. */
mem.memory_size = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment