@@ -13,6 +13,9 @@
#include "qemu/accel.h"
#include "sysemu/kvm.h"
+struct AccelvCPUState {
+};
+
typedef struct KVMSlot
{
hwaddr start_addr;
@@ -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;
}
@@ -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;
}
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(-)