qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: aliguori@us.ibm.com, Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Use msr list to load and save msrs
Date: Tue, 27 Oct 2009 11:32:48 +0100	[thread overview]
Message-ID: <20091027103248.GB3627@mothafucka.localdomain> (raw)
In-Reply-To: <4AE6CAA5.80406@redhat.com>

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

      reply	other threads:[~2009-10-27 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-26 18:26 [Qemu-devel] [PATCH] Use msr list to load and save msrs Glauber Costa
2009-10-27 10:01 ` [Qemu-devel] " Avi Kivity
2009-10-27 10:19   ` Glauber Costa
2009-10-27 10:25     ` Avi Kivity
2009-10-27 10:32       ` Glauber Costa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091027103248.GB3627@mothafucka.localdomain \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).