From patchwork Mon Oct 24 11:34:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 8375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp393941wru; Mon, 24 Oct 2022 04:38:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZTUBWy3vgI5A4vKkemWtaW2+1MJ3drHTyWkAOV3TOJVxAW4WnoXm1UZ28AYHnFryW4c7R X-Received: by 2002:a17:907:1623:b0:78d:9e8b:171d with SMTP id hb35-20020a170907162300b0078d9e8b171dmr27014509ejc.309.1666611525215; Mon, 24 Oct 2022 04:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666611525; cv=none; d=google.com; s=arc-20160816; b=Zb+fpBKpAOy/DGwX9aGUljeoVVzGxya4E00JE6WHeFEa4Wh54IivISOCmRJgkz7k15 J7aHNqBdoBX8/j1XOmSKEWAEw4tKb6fkBvbeZTMwXu9QtQ37NCs8XyjmPSXRaexBu50I zvefHKDLcqZ7cf/Q5/tkbwZMhPhL8ynkcoYfJyQdZQOF4OQIWsU3hsRN76lPb3hk6Cyw xIol8KPro8BjzJFVGExDd+ZlM9CymX5oNHJ3R2UcClgi6so3No0Aj7qYrcfoZQm5dQ5W ptY9d5uAfocycIhWrn/+vbV0w+sHPZNqYOB8LZhNu3QKu47gw78JUxR0SLDtOEMOGzeT AWog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5YaPRYeI2AsPheBSofsV50OmpxolEAvIbe4rB1cNFjM=; b=pcp0iOSvC9bSURs4lWFeqL65fPobdxT9exeIZu4M/sixCQUz/GjN+DP+Pw7savVm48 RT3N5uIb13PnaR2Age1/62giwszd7YGwxoSU4NbY6ofg1kkcBZ6hW+WeeGQ5XsT/DbAm wog8gmjG2kyEBqPZqOGnkYkL/zQr07+yh7fbY4gKskUHlYzj9kbZTgPA/8HZF36QdlSX /sbJR6/uZ/5+Fwvnyy9BeQoWGUhdT558mWIUq8KY7wGitHTW8OAwfAbUfjWaGyKMptIp 16M1eE+clyhyx4kxk026Z7DFypKv5UaNsQKA1C92p86TY5A+t717rj3KdPuQO5RM+RRU zmrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fgPSGzF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc4-20020a1709071c0400b0078d810e16a4si29629734ejc.486.2022.10.24.04.38.21; Mon, 24 Oct 2022 04:38:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fgPSGzF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbiJXLh7 (ORCPT + 99 others); Mon, 24 Oct 2022 07:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbiJXLhc (ORCPT ); Mon, 24 Oct 2022 07:37:32 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AECFC2338C; Mon, 24 Oct 2022 04:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666611441; x=1698147441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6ZWYt19HkbGichJe8gxDpcMzSf3niaLPKuq8RXWtguo=; b=fgPSGzF7FkxLRh2FmhKuElG9S69oXengpHvWxF3vD7nzDVRsqeWrapN7 U3eVAIBIZtQyR7gyLm0Ca03brLBNE7GapEjHB/+QS7fOG+FgZJxc6uII1 MwTaVrDBAFcfCRRAOMS69VDXVWx27B8uRkLyhs+9NxfdhkKAbRZb4gK6G tvs66PPRO9idiR0qAHvtNvjdaNJt8sEAEy3lJulF/Xi/WPcX/DEig9tR7 OMHHrHZtU77/0cAx+FIGv2QzSypC1hKHQUCbGYZAwRh/xCNl0P5LI2wWi fQ1Wcv7WNr7PdmPU8lpkRgMLz0WRF1pgyPViMlgWLjpsfoSYkI5ZjM7Fc Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="371612770" X-IronPort-AV: E=Sophos;i="5.95,209,1661842800"; d="scan'208";a="371612770" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 04:34:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="773784625" X-IronPort-AV: E=Sophos;i="5.95,209,1661842800"; d="scan'208";a="773784625" Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by fmsmga001.fm.intel.com with ESMTP; 24 Oct 2022 04:34:53 -0700 From: Wei Wang To: seanjc@google.com, pbonzini@redhat.com Cc: dmatlack@google.com, vipinsh@google.com, ajones@ventanamicro.com, eric.auger@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Wang Subject: [PATCH v1 02/18] KVM: selftests/kvm_util: use vm->vcpus[] when create vm with vcpus Date: Mon, 24 Oct 2022 19:34:29 +0800 Message-Id: <20221024113445.1022147-3-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221024113445.1022147-1-wei.w.wang@intel.com> References: <20221024113445.1022147-1-wei.w.wang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747568846840376576?= X-GMAIL-MSGID: =?utf-8?q?1747568846840376576?= The kvm_vm struct has been changed to maintain vcpus via an array of vcpu pointers, there is no need to require users to allocate and pass in another vcpu array when create the vm. Signed-off-by: Wei Wang --- tools/testing/selftests/kvm/lib/kvm_util.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 941f6c3ea9dc..1f69f5ca8356 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -371,12 +371,10 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus struct kvm_vm *vm; int i; - TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array"); - vm = __vm_create(mode, nr_vcpus, extra_mem_pages); for (i = 0; i < nr_vcpus; ++i) - vcpus[i] = vm_vcpu_add(vm, i, guest_code); + vm->vcpus[i] = vm_vcpu_add(vm, i, guest_code); return vm; } @@ -385,13 +383,12 @@ struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu, uint64_t extra_mem_pages, void *guest_code) { - struct kvm_vcpu *vcpus[1]; struct kvm_vm *vm; vm = __vm_create_with_vcpus(VM_MODE_DEFAULT, 1, extra_mem_pages, - guest_code, vcpus); + guest_code, NULL); - *vcpu = vcpus[0]; + *vcpu = vm->vcpus[0]; return vm; }