2022-10-24 12:30:59

by Wei Wang

[permalink] [raw]
Subject: [PATCH v1 18/18] KVM: selftests/kvm_create_max_vcpus: check KVM_MAX_VCPUS

If the KVM side max vcpu number is larger than the one supported by the
userspace selftests, adjust the max number.

Signed-off-by: Wei Wang <[email protected]>
---
tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
index 31b3cb24b9a7..bbdb371e21ed 100644
--- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
+++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
@@ -50,6 +50,13 @@ int main(int argc, char *argv[])

pr_info("KVM_CAP_MAX_VCPU_ID: %d\n", kvm_max_vcpu_id);
pr_info("KVM_CAP_MAX_VCPUS: %d\n", kvm_max_vcpus);
+ pr_info("selftests KVM_MAX_VCPUS: %d\n", KVM_MAX_VCPUS);
+
+ if (kvm_max_vcpu_id > KVM_MAX_VCPUS)
+ kvm_max_vcpu_id = KVM_MAX_VCPUS;
+
+ if (kvm_max_vcpus > KVM_MAX_VCPUS)
+ kvm_max_vcpus = KVM_MAX_VCPUS;

/*
* Check that we're allowed to open nr_fds_wanted file descriptors and
--
2.27.0


2022-10-27 00:52:46

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH v1 18/18] KVM: selftests/kvm_create_max_vcpus: check KVM_MAX_VCPUS

On Mon, Oct 24, 2022, Wei Wang wrote:
> If the KVM side max vcpu number is larger than the one supported by the
> userspace selftests, adjust the max number.

No, this defeats the purpose of the test. "create max vCPUs" means "create the
maximum number allowed by KVM", not "create the arbitrary max supported by selftests".