qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Use msr list to load and save msrs


From: Glauber Costa
Subject: [Qemu-devel] Re: [PATCH] Use msr list to load and save msrs
Date: Tue, 27 Oct 2009 11:32:48 +0100
User-agent: Jack Bauer

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 via email to

[Prev in Thread] Current Thread [Next in Thread]