On Wed, Jun 10, 2026, Ritesh Harjani (IBM) wrote:
> Print the vcpu_id and errno when the KVM_CREATE_VCPU ioctl fails, for
> debug purposes.
> This helped in debugging an issue with KVM on PowerVM, where KVM_CREATE_VCPU
> only supports max 2048 vcpus, because the PAPR_HCALL H_GUEST_CREATE_VCPU
> ("Documentation/arch/powerpc/kvm-nested.rst") supports only up to 0-2047
> vcpu_id. However KVM_CAP_MAX_VCPUS capability extension always reports 
> max_vcpus
> as NR_CPUS of the host.
> 
> Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
> ---
>  tools/testing/selftests/kvm/lib/kvm_util.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c 
> b/tools/testing/selftests/kvm/lib/kvm_util.c
> index e00a25f59416..6319e2037882 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -1354,6 +1354,13 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, u32 
> vcpu_id)
>       vcpu->vm = vm;
>       vcpu->id = vcpu_id;
>       vcpu->fd = __vm_ioctl(vm, KVM_CREATE_VCPU, (void *)(unsigned 
> long)vcpu_id);
> +     if (vcpu->fd < 0) {
> +             int saved_errno = errno;
> +
> +             pr_info("Failed KVM_CREATE_VCPU for vcpu_id %u with errno %d\n",
> +                     vcpu_id, saved_errno);
> +             errno = saved_errno;

Sorry, but NAK.  There are myriad failures where printing extra information can
help debug a failure/assert, I don't want to create a slippery slope where the
codebase is littered with extra print statements that someone found useful at
some point.

Reply via email to