From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCz2P-0004BY-Mp for qemu-devel@nongnu.org; Tue, 05 Mar 2013 16:04:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCz28-0002Ki-0Q for qemu-devel@nongnu.org; Tue, 05 Mar 2013 16:04:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCz27-0002Hr-OW for qemu-devel@nongnu.org; Tue, 05 Mar 2013 16:04:23 -0500 Message-ID: <51365E2C.8080402@redhat.com> Date: Tue, 05 Mar 2013 22:05:48 +0100 From: Laszlo Ersek MIME-Version: 1.0 References: <1362435597-20018-1-git-send-email-lersek@redhat.com> <1362435597-20018-3-git-send-email-lersek@redhat.com> <20130305200345.GF21850@vm> In-Reply-To: <20130305200345.GF21850@vm> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] qga: implement qmp_guest_get_vcpus() for Linux with sysfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mdroth Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com 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