[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState |
Date: |
Wed, 3 Mar 2021 19:22:14 +0100 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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 changes
@@ -416,7 +415,6 @@ struct CPUState {
/* 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"
struct AccelvCPUState {
+ /**
+ * @kvm_fd: vCPU file descriptor for KVM
+ */
+ int kvm_fd;
};
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)
vcpu = g_malloc0(sizeof(*vcpu));
vcpu->vcpu_id = kvm_arch_vcpu_id(cpu);
- vcpu->kvm_fd = cpu->kvm_fd;
+ vcpu->kvm_fd = 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)
}
cpu->accel_vcpu = g_new(struct AccelvCPUState, 1);
- cpu->kvm_fd = ret;
+ cpu->accel_vcpu->kvm_fd = ret;
cpu->kvm_state = s;
cpu->vcpu_dirty = true;
@@ -449,7 +449,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
}
cpu->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- cpu->kvm_fd, 0);
+ cpu->accel_vcpu->kvm_fd, 0);
if (cpu->kvm_run == MAP_FAILED) {
ret = -errno;
error_setg_errno(errp, ret,
@@ -2631,7 +2631,7 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
va_end(ap);
trace_kvm_vcpu_ioctl(cpu->cpu_index, type, arg);
- ret = ioctl(cpu->kvm_fd, type, arg);
+ ret = ioctl(cpu->accel_vcpu->kvm_fd, type, arg);
if (ret == -1) {
ret = -errno;
}
--
2.26.2
- Re: [PATCH 04/19] cpu: Croup accelerator-specific fields altogether, (continued)
- [RFC PATCH 05/19] cpu: Introduce AccelvCPUState opaque structure, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 06/19] accel/whpx: Add typedef for 'struct whpx_vcpu', Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 07/19] accel/whpx: Rename struct whpx_vcpu -> AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 08/19] accel/whpx: Use 'accel_vcpu' generic pointer, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 09/19] accel/hax: Add typedef for 'struct hax_vcpu_state', Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 10/19] accel/hax: Use 'accel_vcpu' generic pointer, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 11/19] accel/kvm: Introduce kvm_vcpu_state() helper, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 12/19] accel/kvm: Use kvm_vcpu_state() when possible, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 13/19] accel/kvm: Declare and allocate AccelvCPUState struct, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState,
Philippe Mathieu-Daudé <=
- [RFC PATCH 15/19] accel/kvm: Move the 'kvm_state' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 16/19] accel/kvm: Move the 'kvm_run' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 17/19] accel/hvf: Reduce deref by declaring 'hv_vcpuid_t hvf_fd' on stack, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 18/19] accel/hvf: Declare and allocate AccelvCPUState struct, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 19/19] accel/hvf: Move the 'hvf_fd' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- Re: [RFC PATCH 00/19] accel: Introduce AccelvCPUState opaque structure, Paolo Bonzini, 2021/03/04