lkml.org 
[lkml]   [2021]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILE
Date
Vitaly Kuznetsov <vkuznets@redhat.com> writes:

>>>
>>> + /*
>>> + * Creating KVM_CAP_MAX_VCPUS vCPUs require KVM_CAP_MAX_VCPUS open
>>> + * file decriptors.
>>> + */
>>> + TEST_ASSERT(!getrlimit(RLIMIT_NOFILE, &rl),
>>> + "getrlimit() failed (errno: %d)", errno);
>>
>> And strerror() output too?
>>
>
> Sure, will add in v2.
>

Actually, there are two issues with the code above. First, TEST_ASSERT()
already prints both errno and strerror() (setrlimit() counterpart which
is easier to make fail):

KVM_CAP_MAX_VCPU_ID: 4096
KVM_CAP_MAX_VCPUS: 1024
==== Test Assertion Failure ====
kvm_create_max_vcpus.c:68: !setrlimit(RLIMIT_NOFILE, &rl)
pid=344504 tid=344504 errno=1 - Operation not permitted
1 0x0000000000402485: main at kvm_create_max_vcpus.c:68
2 0x00007fcb2e8b4041: ?? ??:0
3 0x000000000040254d: _start at ??:?
setrlimit() failed, errno: 0

Second, note "errno: 0" above. There's no guarantee that getrlimit()
will be executed before evaluating 'errno' in C. I think I'll just drop
redundant errno printout then.

--
Vitaly

\
 
 \ /
  Last update: 2021-11-23 14:53    [W:0.056 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site