From patchwork Fri May 31 08:52:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 247866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 73A4E2C013D for ; Fri, 31 May 2013 18:52:53 +1000 (EST) Received: from localhost ([::1]:55981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiL4t-0000Ko-Im for incoming@patchwork.ozlabs.org; Fri, 31 May 2013 04:52:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiL4a-0000KQ-Su for qemu-devel@nongnu.org; Fri, 31 May 2013 04:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiL4Y-0006GT-3Y for qemu-devel@nongnu.org; Fri, 31 May 2013 04:52:32 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:43257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiL4X-0006GE-Dh for qemu-devel@nongnu.org; Fri, 31 May 2013 04:52:30 -0400 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 31 May 2013 14:15:51 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 31 May 2013 14:15:50 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id CF85D394004F for ; Fri, 31 May 2013 14:22:24 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4V8qIEl8716686 for ; Fri, 31 May 2013 14:22:18 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4V8qM6A017938 for ; Fri, 31 May 2013 18:52:22 +1000 Received: from localhost.localdomain (dhcp-9-111-29-91.cn.ibm.com [9.111.29.91]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r4V8qIuo017775; Fri, 31 May 2013 18:52:19 +1000 Message-ID: <51A864C2.8090904@linux.vnet.ibm.com> Date: Fri, 31 May 2013 16:52:18 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Paolo Bonzini References: <20130530114604.4b12cb22@redhat.com> <51A77838.4060707@redhat.com> <20130530120832.5abe1c65@redhat.com> <51A8485A.4000605@linux.vnet.ibm.com> <51A85DE8.2090600@redhat.com> In-Reply-To: <51A85DE8.2090600@redhat.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13053108-9574-0000-0000-0000081794DE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.6 Cc: Gleb Natapov , KVM , "Justen, Jordan L" , qemu-devel , Luiz Capitulino , Jordan Justen Subject: [Qemu-devel] [PATCH uq/master] fix double free the memslot in kvm_set_phys_mem X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 235e8982ad 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: Luiz Capitulino Signed-off-by: Xiao Guangrong Reviewed-by: Paolo Bonzini Tested-by: Luiz Capitulino Tested-by: Richard W.M. Jones Reviewed-by: Jordan Justen --- kvm-all.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 8e7bbf8..405480e 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -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;