Create a helper that can be called to reinitialize a particular vCPU, or in other words issue the KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE ioctls accordingly. Make use of the helper from kvm_cpu__arch_init() after the correct target/feature set have been identified. Calling KVM_ARM_VCPU_INIT with the same target more than once is benign. Signed-off-by: Oliver Upton <oupton@xxxxxxxxxx> --- arm/kvm-cpu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c index 1ea56bb..164e399 100644 --- a/arm/kvm-cpu.c +++ b/arm/kvm-cpu.c @@ -35,6 +35,15 @@ int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target) return -ENOSPC; } +static void kvm_cpu__arch_reinit(struct kvm_cpu *vcpu) +{ + if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_INIT, &vcpu->init) < 0) + die("KVM_ARM_VCPU_INIT failed"); + + if (kvm_cpu__configure_features(vcpu)) + die("Unable to configure requested vcpu features"); +} + struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) { struct kvm_arm_target *target; @@ -132,8 +141,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) vcpu->cpu_compatible = target->compatible; vcpu->is_running = true; - if (kvm_cpu__configure_features(vcpu)) - die("Unable to configure requested vcpu features"); + kvm_cpu__arch_reinit(vcpu); return vcpu; } -- 2.35.1.723.g4982287a31-goog