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@xxxxxxxxxx> --- 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