From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2jFP-0006aJ-7m for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:25:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2jFK-0006ZY-Mv for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:25:50 -0400 Received: from [199.232.76.173] (port=48341 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2jFK-0006ZT-6w for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:25:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36690) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2jFJ-0000Q2-Jb for qemu-devel@nongnu.org; Tue, 27 Oct 2009 06:25:45 -0400 Message-ID: <4AE6CAA5.80406@redhat.com> Date: Tue, 27 Oct 2009 12:25:41 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1256581565-20684-1-git-send-email-glommer@redhat.com> <4AE6C517.10806@redhat.com> <20091027101914.GA3627@mothafucka.localdomain> In-Reply-To: <20091027101914.GA3627@mothafucka.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Glauber Costa Cc: aliguori@us.ibm.com, Marcelo Tosatti , qemu-devel@nongnu.org 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) -- error compiling committee.c: too many arguments to function