On 03/04/2013 03:19 PM, Laszlo Ersek wrote:
> Signed-off-by: Laszlo Ersek <ler...@redhat.com>
> ---
>  GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
>  {
> +#if defined(__linux__)

> +
> +        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);

NACK to this portion.  If the file doesn't exist, but the
/sys/devices/system/cpu/cpu%ld/ directory exists, then the cpu should be
treated as always online, and not an error.  In fact, on many machines,
cpu0 does not have an online file precisely because it cannot be taken
offline, even if the rest of the cpus can.  It is also the case that on
older kernels that did not support offline cpus (such as RHEL 5), there
will be no per-cpu online file; but again, such kernels cannot support
hot unplug, so all per-cpu directories imply which cpus are online.  In
other words, you need a sane fallback if the online file does not exist
but the per-cpu directory does exist.

-- 
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