target-arm: Check error conditions on kvm_arm_reset_vcpu
authorChristoffer Dall <christoffer.dall@linaro.org>
Thu, 11 Dec 2014 12:07:53 +0000 (12:07 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 11 Dec 2014 12:07:53 +0000 (12:07 +0000)
When resetting a VCPU we currently call both kvm_arm_vcpu_init() and
write_kvmstate_to_list(), both of which can fail, but we never check the
return value.

The only choice here is to print an error an exit if the calls fail.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1418039630-11773-1-git-send-email-christoffer.dall@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target-arm/kvm.c

index 191e759b3ba5800ee4a6c5624c581e6ec4a1f0e6..4d81f3d765864506b2b5f110a353c69091d264e1 100644 (file)
@@ -442,11 +442,20 @@ bool write_list_to_kvmstate(ARMCPU *cpu)
 
 void kvm_arm_reset_vcpu(ARMCPU *cpu)
 {
+    int ret;
+
     /* Re-init VCPU so that all registers are set to
      * their respective reset values.
      */
-    kvm_arm_vcpu_init(CPU(cpu));
-    write_kvmstate_to_list(cpu);
+    ret = kvm_arm_vcpu_init(CPU(cpu));
+    if (ret < 0) {
+        fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(-ret));
+        abort();
+    }
+    if (!write_kvmstate_to_list(cpu)) {
+        fprintf(stderr, "write_kvmstate_to_list failed\n");
+        abort();
+    }
 }
 
 void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)