Messages in this thread | | | From | Vitaly Kuznetsov <> | Subject | Re: [PATCH] KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILE | Date | Tue, 23 Nov 2021 14:52:41 +0100 |
| |
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
| |