qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Li


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs
Date: Tue, 05 Mar 2013 13:22:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

On 03/05/2013 01:03 PM, mdroth wrote:

>> +        buf = g_strdup_printf("/sys/devices/system/cpu/cpu%ld/online",
>> +                              current);
>> +        f = fopen(buf, "r");
>> +        if (f == NULL) {
>> +            error_setg_errno(&local_err, errno, "fopen(\"%s\", \"r\")", 
>> buf);
>> +        } else {
>> +            unsigned online;
>> +
>> +            if (fscanf(f, "%u", &online) != 1) {
> 
> On Fedora 18 and Ubuntu 12.04 at least there doesn't seem to be per-cpu
> values for online/offline/etc, but instead just a 'global' entry at
> /sys/devices/system/cpu/{online,offline} that provides a range. This is
> what's currently described in
> linux/Documentation/ABI/testing/sysfs-devices-system-cpu as well.

Actually, there is both.  Here's what I have on my 2-cpu laptop, running
Fedora 18:

# find /sys/devices/system/cpu/ -name online
/sys/devices/system/cpu/cpu1/online
/sys/devices/system/cpu/online

Notice that there is NO /sys/devices/system/cpu/cpu0/online, because
this particular laptop's chipset requires that cpu0 ALWAYS be online.
The per-cpu online file exists only for cpus that can safely be
offlined; if it does not exist, then you must leave that cpu on.

> 
> Is that file also available on the distro you're testing with? Hopefully
> there's a single interfaces we can rely on.

Libvirt also relies on the per-cpu online files, and hasn't had any
complaints across the distros.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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