From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2j9E-00059o-CS for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:19:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2j99-000573-36 for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:19:27 -0400 Received: from [199.232.76.173] (port=59801 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2j98-00056l-Mg for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:19:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16938) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2j97-0007XO-Ob for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:19:22 -0400 Date: Tue, 27 Oct 2009 11:19:14 +0100 From: Glauber Costa Message-ID: <20091027101914.GA3627@mothafucka.localdomain> References: <1256581565-20684-1-git-send-email-glommer@redhat.com> <4AE6C517.10806@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AE6C517.10806@redhat.com> Subject: [Qemu-devel] Re: [PATCH] Use msr list to load and save msrs List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: aliguori@us.ibm.com, Marcelo Tosatti , qemu-devel@nongnu.org On Tue, Oct 27, 2009 at 12:01:59PM +0200, Avi Kivity wrote: > On 10/26/2009 08:26 PM, Glauber Costa wrote: >> + >> + kvm_msr_list = kvm_get_msr_list(env); >> + if (!kvm_msr_list) { >> + printf("FAILED\n"); >> + return -1; >> + } >> + >> + msr_data.info.nmsrs = kvm_msr_list->nmsrs; >> + >> + for (i = 0; i< kvm_msr_list->nmsrs; i++) { >> + uint64_t *data = kvm_get_msr_data_addr(env, kvm_msr_list->indices[i]); >> + msrs[i].index = kvm_msr_list->indices[i]; >> + if (data != NULL) { >> + msrs[i].data = *data; >> + } >> + } >> >> return kvm_vcpu_ioctl(env, KVM_SET_MSRS,&msr_data); >> >> > > Aren't you leaking the msr list structure? > > Best to get it once during setup and reuse it later. That's exactly what the function kvm_get_msr_list() does. it allocs the structure the first time we use, and in subsequent times, just return it.