kvm: libkvm: accept EAGAIN to restart kvm_run

With this patch, when the kernel exits with errno of EAGAIN, kvm_run
is restarted like EINTR. It is a preparation patch for SMP using
in-kernel APIC.

This patch also fixes a duplication bug of pre_kvm_run

Signed-off-by: Qing He <qing.he@intel.com>

---
 user/kvmctl.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 31e3494..795e7b3 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -1084,11 +1084,10 @@ again:
 	r = pre_kvm_run(kvm, vcpu);
 	if (r)
 	    return r;
-	pre_kvm_run(kvm, vcpu);
 	r = ioctl(fd, KVM_RUN, 0);
 	post_kvm_run(kvm, vcpu);
 
-	if (r == -1 && errno != EINTR) {
+	if (r == -1 && errno != EINTR && errno != EAGAIN) {
 		r = -errno;
 		printf("kvm_run: %m\n");
 		return r;

