From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
linux-kernel@vger.kernel.org
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 [thread overview]
Message-ID: <877dczm11y.fsf@redhat.com> (raw)
In-Reply-To: <87czmsm5iv.fsf@redhat.com>
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
prev parent reply other threads:[~2021-11-23 13:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 17:19 [PATCH] KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILE Vitaly Kuznetsov
2021-11-22 17:38 ` Sean Christopherson
2021-11-22 18:03 ` Vitaly Kuznetsov
2021-11-23 13:52 ` Vitaly Kuznetsov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877dczm11y.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox