[libvirt] [PATCH 2/2] FreeBSD: stub out CPU affinity functions.
Peter Krempa
pkrempa at redhat.com
Wed Dec 19 11:30:33 UTC 2012
On 12/16/12 23:21, Peter Krempa wrote:
> On 12/16/12 15:47, Roman Bogorodskiy wrote:
>> ---
>> src/util/processinfo.c | 22 ++++++++++++++++++++++
>> 1 file changed, 22 insertions(+)
>>
>> diff --git a/src/util/processinfo.c b/src/util/processinfo.c
>> index b1db049..4822bcc 100644
>> --- a/src/util/processinfo.c
>> +++ b/src/util/processinfo.c
>> @@ -168,6 +168,28 @@ realloc:
>> return 0;
>> }
>>
>> +#elif defined(__FreeBSD__)
>> +
>> +int virProcessInfoSetAffinity(pid_t pid ATTRIBUTE_UNUSED,
>> + virBitmapPtr map ATTRIBUTE_UNUSED)
>> +{
>> + return 0;
>
> Hmm, if the platform doesn't support setting of cpu affinity you should
> report an error here and return failure. Otherwise the user will think
> that the affinity was set successfully and when he tries to read it
> (code below) he/she gets incorrect value.
I have a version that checks if the affinity requested is non-default
and reports error in that case. I will post the patch for review.
>
>> +}
>> +
>> +int virProcessInfoGetAffinity(pid_t pid ATTRIBUTE_UNUSED,
>> + virBitmapPtr *map,
>> + int maxcpu)
>> +{
>> + *map = virBitmapNew(maxcpu);
>> + if (!map) {
Also this check isn't right as it checks the value provided by the
caller for NULL instead of the allocated memory region.
>> + virReportOOMError();
>> + return -1;
>> + }
>> + virBitmapSetAll(*map);
>
> Okay, this is fair enough, but you have to fail in the setting call so
> that this function doesn't lie to the user.
>
>> +
>> + return 0;
>> +}
>> +
>> #else /* HAVE_SCHED_GETAFFINITY */
>>
>> int virProcessInfoSetAffinity(pid_t pid ATTRIBUTE_UNUSED,
>>
>
> Peter
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
More information about the libvir-list
mailing list