From nobody Mon Feb 9 20:13:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614795841; cv=none; d=zohomail.com; s=zohoarc; b=MwMhz9zTS8xVOh34uS4iYwGklGsGf/Kr+MVYltOKAgaJNDFOUa5D2TJPy6hxPhde8Im5y5mSdO6R2dhzlzJcybmEu4QEop83AcOd9sw4wAk7iUDyS7PGg04rAfZ7A1AU484wSaKmS2SJtB8IJe7QBtRV1DMyhsqQd9Tqgs9wi4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614795841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jSFJR2T0y61cEAykVjSlmIgXEHeIk/fhpqbk5zPRC7k=; b=P4dCgGRz9WtdBO7h8oXZWhQPMHab79WlMF+JaOxRq9NTN1VpqLdOOCh8y370TnalkPtd3KEOInVR/XjpSR67HOSP+1UVDa5TMhAXrYArr5ZRfwDfnv9WODJjkTnzUfQEgk0mwyg62jYH6ribyI5c55Wr7HZSrKQHmBo/YLykfG8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1614795841270388.45936882386354; Wed, 3 Mar 2021 10:24:01 -0800 (PST) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-jUAQSdi3PJ2RHZwCE7llKg-1; Wed, 03 Mar 2021 13:23:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id 75so817462wrl.3 for ; Wed, 03 Mar 2021 10:23:56 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id l15sm6604958wme.43.2021.03.03.10.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 10:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614795840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jSFJR2T0y61cEAykVjSlmIgXEHeIk/fhpqbk5zPRC7k=; b=gX7hae0anrTdXgTNqPq5aFnEKQlf62qJRRK7nuAGjbjvN89lnY/tKJrwY6LT9/mJsnSD4Z lwASpg4upTwkTinnbYCzJlcnagpJ3ApV05r0CK+zjLUbbI0S4IQk5tCLTr9ohV6WU0CmFl rWsCwLEMn9tEQF/WTX+DFbo0Lru/akI= X-MC-Unique: jUAQSdi3PJ2RHZwCE7llKg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jSFJR2T0y61cEAykVjSlmIgXEHeIk/fhpqbk5zPRC7k=; b=qNPbhwCm4XqCKfaFUDQ7kjV6PRkl2r+Q95+sRkHfBuaus9UT+mH/Yd36jlN0VAViwe rKC37vTzYXqi1xG2koxtYlwV47wGOz/ZhqGAovDPXWg+FlqaVIK4nzN7NOFpHtsa/7rC MmIMHv+CE7Qq3739biFNd2G4eqpXdJ2dKTpJhGu4wkehO8BY4MaiYWtNIXivCIVum1Yk ck0LCowQmUPqzy5J9aveFz3JZoiWtX1jOetpcLGSnf4B3CZfE1XR59Blo0lVgAcTuqfx fKkRIHTRxdxvEJK9bq3fAojpwbmIn3+uT1KieDicC8/aB0RW66WxGwB9KLnta8cSaGie eQkA== X-Gm-Message-State: AOAM530E8JOu1EKOU9QkdPqQKnzOQHehFPIVrB7CdSZZrWzeJ8KjcX8w DxDHpLw9vyx3rDJ0qeKtROhRGuI7KHVVx7MFCcd6vVVrQdytz5CrkPqKEiwLgvkOZjebETFdsm6 63Z+qRfLOcKXg1Q== X-Received: by 2002:adf:f941:: with SMTP id q1mr29310610wrr.189.1614795835227; Wed, 03 Mar 2021 10:23:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+U5MnteFFnH0DvjeZoCaADZkKnu3iy+W7Ik0whDtmDP3G8okupBtGMb7OSZvJC7sHUOE4eg== X-Received: by 2002:adf:f941:: with SMTP id q1mr29310594wrr.189.1614795835090; Wed, 03 Mar 2021 10:23:55 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Cornelia Huck , Richard Henderson , Sunil Muthuswamy , Marcelo Tosatti , David Gibson , Marcel Apfelbaum , kvm@vger.kernel.org, Wenchao Wang , Thomas Huth , Cameron Esfahani , Paolo Bonzini , David Hildenbrand , Roman Bolshakov , Peter Maydell , Greg Kurz , qemu-arm@nongnu.org, Halil Pasic , Colin Xu , Claudio Fontana , qemu-ppc@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, haxm-team@intel.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState Date: Wed, 3 Mar 2021 19:22:14 +0100 Message-Id: <20210303182219.1631042-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210303182219.1631042-1-philmd@redhat.com> References: <20210303182219.1631042-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 2 -- include/sysemu/kvm_int.h | 4 ++++ accel/kvm/kvm-all.c | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 65ff8d86dbc..ca2526e6a23 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -314,7 +314,6 @@ struct AccelvCPUState; * @opaque: User data. * @mem_io_pc: Host Program Counter at which the memory was accessed. * @accel_vcpu: Pointer to accelerator-specific AccelvCPUState field. - * @kvm_fd: vCPU file descriptor for KVM. * @work_mutex: Lock to prevent multiple access to @work_list. * @work_list: List of pending asynchronous work. * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all ch= anges @@ -416,7 +415,6 @@ struct CPUState { =20 /* Accelerator-specific fields. */ struct AccelvCPUState *accel_vcpu; - int kvm_fd; struct KVMState *kvm_state; struct kvm_run *kvm_run; int hvf_fd; diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index f57be10adde..3bf75e62293 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -14,6 +14,10 @@ #include "sysemu/kvm.h" =20 struct AccelvCPUState { + /** + * @kvm_fd: vCPU file descriptor for KVM + */ + int kvm_fd; }; =20 typedef struct KVMSlot diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4ccd12ea56a..1c08ff3fbe0 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -387,7 +387,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) =20 vcpu =3D g_malloc0(sizeof(*vcpu)); vcpu->vcpu_id =3D kvm_arch_vcpu_id(cpu); - vcpu->kvm_fd =3D cpu->kvm_fd; + vcpu->kvm_fd =3D cpu->accel_vcpu->kvm_fd; QLIST_INSERT_HEAD(&kvm_state->kvm_parked_vcpus, vcpu, node); err: return ret; @@ -436,7 +436,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) } =20 cpu->accel_vcpu =3D g_new(struct AccelvCPUState, 1); - cpu->kvm_fd =3D ret; + cpu->accel_vcpu->kvm_fd =3D ret; cpu->kvm_state =3D s; cpu->vcpu_dirty =3D true; =20 @@ -449,7 +449,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) } =20 cpu->kvm_run =3D mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHA= RED, - cpu->kvm_fd, 0); + cpu->accel_vcpu->kvm_fd, 0); if (cpu->kvm_run =3D=3D MAP_FAILED) { ret =3D -errno; error_setg_errno(errp, ret, @@ -2631,7 +2631,7 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...) va_end(ap); =20 trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg); - ret =3D ioctl(cpu->kvm_fd, type, arg); + ret =3D ioctl(cpu->accel_vcpu->kvm_fd, type, arg); if (ret =3D=3D -1) { ret =3D -errno; } --=20 2.26.2