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: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 20/34] scripts/kvm/kvm_stat: Cleanup cpu list retrieval
Date: Thu, 7 Jan 2016 16:21:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0


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



reply via email to

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