[PATCH 04/10] qemu-kvm: Refactor vm exit in kvm_run

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use kvm_vcpu_ioctl to simplify the vm exit code a bit. This increases
the similarity to upstream.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 qemu-kvm.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 19ede6e..e5b8e42 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -299,7 +299,6 @@ static int kvm_run(CPUState *env)
 {
     int r;
     struct kvm_run *run = env->kvm_run;
-    int fd = env->kvm_fd;
 
   again:
     if (env->kvm_vcpu_dirty) {
@@ -319,22 +318,20 @@ static int kvm_run(CPUState *env)
         env->exit_request = 0;
         pthread_kill(env->thread->thread, SIG_IPI);
     }
-    r = ioctl(fd, KVM_RUN, 0);
-
-    if (r == -1 && errno != EINTR && errno != EAGAIN) {
-        r = -errno;
-        post_kvm_run(env);
-        fprintf(stderr, "kvm_run: %s\n", strerror(-r));
-        return r;
-    }
+    r = kvm_vcpu_ioctl(env, KVM_RUN, 0);
 
     post_kvm_run(env);
 
     kvm_flush_coalesced_mmio_buffer();
 
-    if (r == -1) {
+    if (r == -EINTR || r == -EAGAIN) {
         return 1;
     }
+    if (r < 0) {
+        fprintf(stderr, "kvm_run: %s\n", strerror(-r));
+        return r;
+    }
+
     if (1) {
         switch (run->exit_reason) {
         case KVM_EXIT_UNKNOWN:
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux