Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3891643imu; Mon, 10 Dec 2018 09:24:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/U6wmS64hA1i9J1c5oOyMKsnLEOkiyMReen0il1URuDrHsgy/mRIIXuuctVLutwWQ+oPM15 X-Received: by 2002:a63:5d55:: with SMTP id o21mr11362034pgm.92.1544462658880; Mon, 10 Dec 2018 09:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544462658; cv=none; d=google.com; s=arc-20160816; b=Cl48dZXYjwQGrrsaThALm480I2SCn7HPWgLuT7HFnmT4F4nDbCbWK89xV/zhMHbdva r41VcvG2dlhISILyefSdqdfOgjtrYPsum+jJCjtCBgtMPJY2wXMwg15tq2sfbkAV4Tw/ X3kXW/2ih6cAFxG2uqGl9t+MdGuE4ywlse/EUN2D7cwlAVj37mRbUidMqvW/jGHu8gL/ ev+E9B7/9Lj0A/MqbCNhgyccxE7VHHiay+3jd60jaY2OlOx53UXRduCl4SJ20U4O/QG2 mRt7KjJ3+7a++5XnOfKDQEuGqSdUsQMfxdIgWDLbSilr/cLVbEZkZ50NEqs/1Axwy2H6 PkGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=n7NAmXRZl4pe9l2OV4vuGQhXSGPkzrcfkZMbx5MdqQo=; b=Li5eaoPHBY/3Hf/t4itMLzTEv0wOqPjEr6VS0ua9kF1VE1wOSRECs/QUev6NBvDjWp bbCuvTgmzwD+/UrzM/hkDoycsqx+DhEC3Ay//KNz71+KdFhpih97Ei1oE9qqjVYMAaIl rk1D0GAtSPde7Jg79/ZWH1tSqCIXDQMBKNz0T1l74ofdRXThinPOrUI8JKnR9gwkQzVG cKsIK19kz3oThC9UPgVIV56LScvYP1AdZ2R0N0HMJip23wusV4sHHQdSQ6VMpOBZpzXL /yP0TpMgFVTc3iZ/Kn2nsFflvjiLWM2rYiyZjLSFKX1WtUV4CrYye/InHNepBusKx/H2 P4Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15si10586828plk.357.2018.12.10.09.24.03; Mon, 10 Dec 2018 09:24:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729230AbeLJRWX (ORCPT + 99 others); Mon, 10 Dec 2018 12:22:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37376 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729214AbeLJRWW (ORCPT ); Mon, 10 Dec 2018 12:22:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C26DB307EAA1; Mon, 10 Dec 2018 17:22:21 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ACD86061B; Mon, 10 Dec 2018 17:22:18 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org, Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , x86@kernel.org, "Michael Kelley (EOSG)" , Eduardo Habkost Subject: [PATCH v2 6/7] KVM: selftests: implement an unchecked version of vcpu_ioctl() Date: Mon, 10 Dec 2018 18:21:58 +0100 Message-Id: <20181210172159.410-7-vkuznets@redhat.com> In-Reply-To: <20181210172159.410-1-vkuznets@redhat.com> References: <20181210172159.410-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 10 Dec 2018 17:22:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case we want to test failing ioctls we need an option to not fail. Following _vcpu_run() precedent implement _vcpu_ioctl(). Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/include/kvm_util.h | 2 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index a4e59e3b4826..539028f91582 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -78,6 +78,8 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, void vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl, void *arg); +int _vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, unsigned long ioctl, + void *arg); void vm_ioctl(struct kvm_vm *vm, unsigned long ioctl, void *arg); void vm_mem_region_set_flags(struct kvm_vm *vm, uint32_t slot, uint32_t flags); void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid, int pgd_memslot, diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 1b41e71283d5..9635090cd699 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1269,6 +1269,16 @@ int _vcpu_sregs_set(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_sregs *sregs) */ 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) { struct vcpu *vcpu = vcpu_find(vm, vcpuid); int ret; @@ -1276,8 +1286,8 @@ void vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid, TEST_ASSERT(vcpu != NULL, "vcpu not found, vcpuid: %u", vcpuid); ret = ioctl(vcpu->fd, cmd, arg); - TEST_ASSERT(ret == 0, "vcpu ioctl %lu failed, rc: %i errno: %i (%s)", - cmd, ret, errno, strerror(errno)); + + return ret; } /* -- 2.19.2