From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyNI-0001jG-I7 for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:22:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCyNG-0006Ue-Vd for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:22:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCyNG-0006UX-O6 for qemu-devel@nongnu.org; Tue, 05 Mar 2013 15:22:10 -0500 Message-ID: <513653EB.8000204@redhat.com> Date: Tue, 05 Mar 2013 13:22:03 -0700 From: Eric Blake 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: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2SRUKIDWDSFDLBADNPFAW" 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, Laszlo Ersek , qemu-devel@nongnu.org, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2SRUKIDWDSFDLBADNPFAW Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/05/2013 01:03 PM, mdroth wrote: >> + buf =3D g_strdup_printf("/sys/devices/system/cpu/cpu%ld/onlin= e", >> + current); >> + f =3D fopen(buf, "r"); >> + if (f =3D=3D NULL) { >> + error_setg_errno(&local_err, errno, "fopen(\"%s\", \"r\")= ", buf); >> + } else { >> + unsigned online; >> + >> + if (fscanf(f, "%u", &online) !=3D 1) { >=20 > 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. >=20 > Is that file also available on the distro you're testing with? Hopefull= y > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2SRUKIDWDSFDLBADNPFAW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRNlPrAAoJEKeha0olJ0NqSVUH/3Ez+EnZSENO8WQi2EzN3xbJ MgxExDzQ2kUZfg4+iLTeCl4F0oB5fMKEpN4Uv99ZParB5gAJ5JcqcW9YmYEDB1jW qbUCg4qlF9wTb29sTB1tqvK+MQ8IXb63cm2rmbxFvSkTP1l7VBj2bQTkZqtEQg06 8FzSs+OkNcBfEKdZkNyrRN5w358RPpL2kwwxe16nZ23SR07vI1MdODNoD+h3GRaJ TmdeSn3mCtQbAMrPrOGZ57gQb9U4N+MIctiB5LIiFZ8h4Oxr5pSIEIs9+ylVX7IH JgyUsVfMzryKHiTmfzsFOoFEXlet2hQNxiYFaiG3L28TJgwcB1RRmniN8I0psMw= =VABk -----END PGP SIGNATURE----- ------enig2SRUKIDWDSFDLBADNPFAW--