From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCynU-0007Vq-2b for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:49:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCynR-0005q8-EQ for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:49:16 -0500 Received: from mail-oa0-f49.google.com ([209.85.219.49]:64539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCynR-0005pv-8Z for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:49:13 -0500 Received: by mail-oa0-f49.google.com with SMTP id j6so11360603oag.8 for ; Tue, 05 Mar 2013 12:49:12 -0800 (PST) Sender: fluxion Date: Tue, 5 Mar 2013 14:45:13 -0600 From: mdroth Message-ID: <20130305204513.GH21850@vm> References: <1362435597-20018-1-git-send-email-lersek@redhat.com> <1362435597-20018-3-git-send-email-lersek@redhat.com> <20130305200345.GF21850@vm> <513653EB.8000204@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <513653EB.8000204@redhat.com> 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: Eric Blake Cc: pbonzini@redhat.com, Laszlo Ersek , qemu-devel@nongnu.org, lcapitulino@redhat.com On Tue, Mar 05, 2013 at 01:22:03PM -0700, Eric Blake wrote: > 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 Ahh, didn't think to check the others. This seems to be the case for me as well. I agree on your later note about special casing this though. > 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 >