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: Laszlo Ersek
Subject: Re: [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs
Date: Tue, 05 Mar 2013 22:05:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130216 Thunderbird/17.0.3

On 03/05/13 21:03, mdroth wrote:> On Mon, Mar 04, 2013 at 11:19:56PM +0100, 
Laszlo Ersek wrote:

>> +#if defined(__linux__)
>
> There's a section in commands-posix.c set aside under "linux-specific
> implementations" for these, and another underneath for stubs so we can
> avoid having too many ifdef's.

I'll check it, thanks.

>> +        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.
>
> Is that file also available on the distro you're testing with? Hopefully
> there's a single interfaces we can rely on.

On RHEL-6, both "/sys/devices/system/cpu/cpu*/online" and
"/sys/devices/system/cpu/online " are available.

On RHEL-5, only "/sys/devices/system/cpu/cpu*/online" is available.

"/sys/devices/system/cpu/cpu*/online" is documented in
"Documentation/cpu-hotplug.txt", in all of RHEL-5, RHEL-6, and upstream
Linux.

            #pwd
            #/sys/devices/system/cpu
            #ls -l
            total 0
            drwxr-xr-x  10 root root 0 Sep 19 07:44 .
            drwxr-xr-x  13 root root 0 Sep 19 07:45 ..
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu0
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu1
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu2
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu3
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu4
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu5
            drwxr-xr-x   3 root root 0 Sep 19 07:44 cpu6
            drwxr-xr-x   3 root root 0 Sep 19 07:48 cpu7

    Under each directory you would find an "online" file which is the control
    file to logically online/offline a processor.

    Q: Does hot-add/hot-remove refer to physical add/remove of cpus?
    A: The usage of hot-add/remove may not be very consistently used in the 
code.
    CONFIG_HOTPLUG_CPU enables logical online/offline capability in the kernel.
    To support physical addition/removal, one would need some BIOS hooks and
    the platform should have something like an attention button in PCI hotplug.
    CONFIG_ACPI_HOTPLUG_CPU enables ACPI support for physical add/remove of 
CPUs.

The kernels you mention may not have CONFIG_HOTPLUG_CPU enabled
(consequently they would probably not support the functionality either).

... I just checked "/boot/config-3.8.2-201.fc18.x86_64" in
"kernel-3.8.2-201.fc18.x86_64.rpm" and all required config options seem
to be set. I checked on a much older F18 guest as well
(3.6.10-4.fc18.x86_64), and the per-cpu "online" files are there. (Not
for cpu0, but I'll address that in response to Eric's review.) I'm not
sure why you don't get them under F18.

Thanks
Laszlo



reply via email to

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