[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 13/19] accel/kvm: Declare and allocate AccelvCPUState struct
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 13/19] accel/kvm: Declare and allocate AccelvCPUState struct |
Date: |
Wed, 3 Mar 2021 19:22:13 +0100 |
In preparation of moving KVM-specific fields from CPUState
to the accelerator-specific AccelvCPUState structure, first
declare it empty and allocate it. This will make the following
commits easier to review.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
include/sysemu/kvm_int.h | 3 +++
accel/kvm/kvm-all.c | 5 +++++
target/s390x/kvm.c | 2 +-
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index ccb8869f01b..f57be10adde 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -13,6 +13,9 @@
#include "qemu/accel.h"
#include "sysemu/kvm.h"
+struct AccelvCPUState {
+};
+
typedef struct KVMSlot
{
hwaddr start_addr;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 8259e89bbaf..4ccd12ea56a 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -399,6 +399,7 @@ void kvm_destroy_vcpu(CPUState *cpu)
error_report("kvm_destroy_vcpu failed");
exit(EXIT_FAILURE);
}
+ g_free(cpu->accel_vcpu);
}
static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id)
@@ -434,6 +435,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
goto err;
}
+ cpu->accel_vcpu = g_new(struct AccelvCPUState, 1);
cpu->kvm_fd = ret;
cpu->kvm_state = s;
cpu->vcpu_dirty = true;
@@ -468,6 +470,9 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
kvm_arch_vcpu_id(cpu));
}
err:
+ if (ret < 0) {
+ g_free(cpu->accel_vcpu);
+ }
return ret;
}
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d8ac12dfc11..cf6790b2678 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -2085,7 +2085,7 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t
cpu_state)
int ret;
/* the kvm part might not have been initialized yet */
- if (CPU(cpu)->kvm_state == NULL) {
+ if (CPU(cpu)->accel_vcpu == NULL) {
return 0;
}
--
2.26.2
- [PATCH 04/19] cpu: Croup accelerator-specific fields altogether, (continued)
- [PATCH 04/19] cpu: Croup accelerator-specific fields altogether, Philippe Mathieu-Daudé, 2021/03/03
- [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é <=
- [RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [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