qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 20/34] scripts/kvm/kvm_stat: Cleanup cpu list re


From: Janosch Frank
Subject: Re: [Qemu-devel] [PATCH 20/34] scripts/kvm/kvm_stat: Cleanup cpu list retrieval
Date: Thu, 7 Jan 2016 17:56:27 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 01/07/2016 04:21 PM, Paolo Bonzini wrote:
> 
> 
> On 10/12/2015 13:12, Janosch Frank wrote:
>> +    with open('/sys/devices/system/cpu/online') as cpu_list:
>> +        cpu_string = cpu_list.readline()
>> +        cpus = cpu_string.split(',')
>> +
>> +        for cpu in cpus:
>> +            if '-' not in cpu:
>> +                cpulist.append(int(cpu))
>> +            else:
>> +                cpu_range = cpu.split('-')
>> +                cpulist.extend(range(int(cpu_range[0]),
>> +                                     int(cpu_range[1]) + 1))
> 
> Perhaps you can move everything after readline() to a separate function?
> 
> Paolo
The string analysis to extract the cpu numbers is only needed in the
get_online_cpus function where it resides, so why do you want to split
this function into two?

Its also only a few lines which are easy to read.




reply via email to

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