Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp774095pxp; Fri, 11 Mar 2022 14:47:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfdqW6oD4A9iXBrI5Ovm2vO2VG8M6FHwGCsTe4pBDv6mDKZytkr5mIzzvRa1Saovq4FsQC X-Received: by 2002:a63:8643:0:b0:37c:9aff:13bf with SMTP id x64-20020a638643000000b0037c9aff13bfmr10265528pgd.392.1647038832926; Fri, 11 Mar 2022 14:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647038832; cv=none; d=google.com; s=arc-20160816; b=Qr5gfb9QaSNwx/X6km7s9A4XbYYltctkY4zxaZ8gflOvWocjvnu5x2Zv54bqrxNNYC J6GK6vRW8QCeAppr/pLwAnriiPiifRPt4fD84yg3nYKFBgWvJgumKCOkhxv8WDxsb6mx zfdxFz6IdfLk35X5aPhgJBGuBRstU8g1ypEt88bV5NRyDoubsOJ9PD/H5FKKr5OH4UWq p//gPdvmd++g+cPZan06MKyolmJ6Shs1rocBmokn69G31JUdc0YZY8512LobU9C2r2Uy XLsE/N0qge4J+C3vEioc1+h6yjEiuI3lD2rrlvDdjaW0dTiU3OqJbszvPg05m3FwDMvW G3FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=OGdeptO7GDLnSXzyDOFVHXNsC4c15uqK/LE1tOkpfmU=; b=kLddOvEMuzygE38lOIu52FcfbgBhlch2RKe5TJ+O4H55FCTcIWoB4R0ymRAvkIs3gd T7Gdn4o0PJPbN+Ie8wXAGLhe1PS4QaYA7GBY6BKKeCEsK8w7Lf3EJemN4N1IO1dY2m0g eheDj0y/QjUQpAf1WRYzUewwf/+5Xz3lXAIVDK+CC5HVIpPRTqYJDhewqHFlfYEv1s2W k+rK3z/hKATU3Cdvm8jtGt66rIWPpXVAhEZf6Q1oD0UGYZ6xOzMUtxcXN182jtE2ej8N MNpqE8DYp17b9mDDm8GR1+wGjme27KCXjfuSHxdJst+TwZ+F1ZDzf9EwqHGfbNJ9cdz1 pqxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nVV1f4vO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x61-20020a17090a6c4300b001bd1e20d3c4si8923873pjj.78.2022.03.11.14.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:47:12 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nVV1f4vO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A11438B126; Fri, 11 Mar 2022 14:01:38 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346572AbiCKFwd (ORCPT + 99 others); Fri, 11 Mar 2022 00:52:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346534AbiCKFwQ (ORCPT ); Fri, 11 Mar 2022 00:52:16 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7A59ED94F for ; Thu, 10 Mar 2022 21:51:13 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id h12-20020a63530c000000b0037c8f45bf1bso4234654pgb.7 for ; Thu, 10 Mar 2022 21:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=OGdeptO7GDLnSXzyDOFVHXNsC4c15uqK/LE1tOkpfmU=; b=nVV1f4vOqOQ6LkkTLgIp1v/U7+YVR4vCaUcitzqAj2VPCGFry8haznr5aq/oNfwSzD lw8l7HuSlPBKXFGvrKQ7zrpUJF0I3ABv4k9/Fro/uDxdXMQoSALr0R+Y6mgosFFwjJyN KnRPzW2iUi7RjS6KiahtlXXHRFvN+/dtEpQV1EeZM7eS50I7ZtCQ03XWJZ+Xr+uF32QO hDq68lRTTKUx+oF9CkApTK6R8DzeDSNimlAe5vrB9t5FxRxozPVgUqpqm3QhtM4p9Jk9 zqpj+qu9F4mpNvrGHjX5KoWhwHSq48GWBmXME48YaO/+65PbXjX8XITRl4xbGl9GBCyN N8Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=OGdeptO7GDLnSXzyDOFVHXNsC4c15uqK/LE1tOkpfmU=; b=6851wgdpVres2kt+yYBuZHRhTzAWSc8NcUWgZJWiYa9lHHeMtiz2Q4P3gDL9+6HNJC ArviDRnzK8c0T+J64C2A7vW1WIV1p3BK3YLadbP64oY6t/FcR/3fj2d3+sHCotes2f5D Wl56s/SUbNuVljdMikiHd5Pjfz9h6Ec1mnvMlVClys7O9R+fBE6Pwtyy+neeBOVdMj5m GsU/MBvzlhCKrtOeDPmgFdwt3IWJiX8g2i1FJcUpQRFknI5VmVjCRdRX1+NiV1ogeSEc dr5Ok3SSQMRGiUh6ouuZ2xo1zllA4kXzCgRtzzfKI2p7uWbntEcKB04yjJ5l06KhyJhw d1+A== X-Gm-Message-State: AOAM532TIl/N2d1v51j/EqB7J3LU+qcsqtyCix3KHR4AxabH6ZR/rNvk CWNyBAQaaVpnTLu9lWgUl+ljoVFrhek1+XVIZFvlaASUnnTyP3HEVP38Zxc0M9zdIt8HTaXfv5c JoOxwmz+JAOvGEajKTN++ioI3EYnVguaSeOC/2vP1Q2FStDMgV631ZtXwLHn/3RrR7qlvSg== X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:ee95:b0:151:8518:9f49 with SMTP id a21-20020a170902ee9500b0015185189f49mr8653226pld.1.1646977873268; Thu, 10 Mar 2022 21:51:13 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 11 Mar 2022 05:49:15 +0000 In-Reply-To: <20220311055056.57265-1-seanjc@google.com> Message-Id: <20220311055056.57265-5-seanjc@google.com> Mime-Version: 1.0 References: <20220311055056.57265-1-seanjc@google.com> X-Mailer: git-send-email 2.35.1.723.g4982287a31-goog Subject: [RFC PATCH 004/105] KVM: selftests: Make vcpu_ioctl() a wrapper to pretty print ioctl name From: Sean Christopherson To: linux-kernel@vger.kernel.org Cc: Sean Christopherson Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Deliberately do not use __stringify(), as that will expand the ioctl all the way down to its numerical sequence, the intent is print the name of the macro. Signed-off-by: Sean Christopherson --- .../selftests/kvm/include/kvm_util_base.h | 12 +++++-- tools/testing/selftests/kvm/lib/kvm_util.c | 31 +++++-------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index 77aaac4d344e..28440c12ffbc 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -152,10 +152,18 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, uint64_t guest_paddr, uint32_t slot, uint64_t npages, uint32_t flags); -void vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl, - void *arg); +#define __KVM_IOCTL_ERROR(_name, _ret) \ + "%s failed, rc: %i errno: %i (%s)", (_name), (_ret), errno, strerror(errno) + +#define KVM_IOCTL_ERROR(_ioctl, _ret) __KVM_IOCTL_ERROR(#_ioctl, _ret) + +void _vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl, + const char *name, void *arg); int __vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl, void *arg); +#define vcpu_ioctl(vm, vcpuid, ioctl, arg) \ + _vcpu_ioctl(vm, vcpuid, ioctl, #ioctl, arg) + void vm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg); int __vm_ioctl(struct kvm_vm *vm, unsigned long cmd, void *arg); void kvm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg); diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 6f515333abe0..a6675d9aa7d9 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1898,29 +1898,6 @@ void vcpu_set_reg(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_one_reg *reg) ret, errno, strerror(errno)); } -/* - * VCPU Ioctl - * - * Input Args: - * vm - Virtual Machine - * vcpuid - VCPU ID - * cmd - Ioctl number - * arg - Argument to pass to the ioctl - * - * Return: None - * - * Issues an arbitrary ioctl on a VCPU fd. - */ -void vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, - unsigned long cmd, void *arg) -{ - int ret; - - ret = __vcpu_ioctl(vm, vcpuid, cmd, arg); - TEST_ASSERT(ret == 0, "vcpu ioctl %lu failed, rc: %i errno: %i (%s)", - cmd, ret, errno, strerror(errno)); -} - int __vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long cmd, void *arg) { @@ -1934,6 +1911,14 @@ int __vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, return ret; } +void _vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long cmd, + const char *name, void *arg) +{ + int ret = __vcpu_ioctl(vm, vcpuid, cmd, arg); + + TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); +} + void *vcpu_map_dirty_ring(struct kvm_vm *vm, uint32_t vcpuid) { struct vcpu *vcpu; -- 2.35.1.723.g4982287a31-goog