Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2joA-0007HA-89 for qemu-devel@nongnu.org; Tue, 27 Oct 2009 07:01:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2jo5-0007FL-En for qemu-devel@nongnu.org; Tue, 27 Oct 2009 07:01:45 -0400 Received: from [199.232.76.173] (port=39017 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2jo5-0007FE-07 for qemu-devel@nongnu.org; Tue, 27 Oct 2009 07:01:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27370) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2jME-00021z-Ec for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:32:55 -0400 Date: Tue, 27 Oct 2009 11:32:48 +0100 From: Glauber Costa Message-ID: <20091027103248.GB3627@mothafucka.localdomain> References: <1256581565-20684-1-git-send-email-glommer@redhat.com> <4AE6C517.10806@redhat.com> <20091027101914.GA3627@mothafucka.localdomain> <4AE6CAA5.80406@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AE6CAA5.80406@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:25:41PM +0200, Avi Kivity wrote: > On 10/27/2009 12:19 PM, Glauber Costa wrote: >> 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. >> > > Oh, somehow I missed that. > > (it's still better form to allocate on initialization, but that's not > really a problem) Yeah... there's no scenarion in which we don't need to allocate it, so it is less confusing, indeed. I'll send that in v2 after people send in (hopefully) more comments