From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1Mw1-0002aW-VZ for qemu-devel@nongnu.org; Thu, 09 Jan 2014 16:14:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1Mw1-0000FO-6B for qemu-devel@nongnu.org; Thu, 09 Jan 2014 16:14:37 -0500 Received: from mail-vb0-x249.google.com ([2607:f8b0:400c:c02::249]:55045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1Mw1-0000F9-1J for qemu-devel@nongnu.org; Thu, 09 Jan 2014 16:14:37 -0500 Received: by mail-vb0-f73.google.com with SMTP id f12so349790vbg.2 for ; Thu, 09 Jan 2014 13:14:36 -0800 (PST) From: thomas knych Date: Thu, 9 Jan 2014 13:14:23 -0800 Message-Id: <1389302063-2432-2-git-send-email-thomaswk@google.com> In-Reply-To: <1389302063-2432-1-git-send-email-thomaswk@google.com> References: <1389302063-2432-1-git-send-email-thomaswk@google.com> Subject: [Qemu-devel] [PATCH 1/1] KVM: Retry KVM_CREATE_VM on EINTR or EAGAIN List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, thomas knych , gleb@redhat.com, digit@google.com Upstreaming this change from Android (https://android-review.googlesource.com/54211). On heavily loaded machines with many VM instances we see KVM_CREATE_VM failing with EINTR/EAGAIN retrying the system call greatly improves reliability. Signed-off-by: thomas knych --- kvm-all.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kvm-all.c b/kvm-all.c index 3937754..29787ae 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1442,8 +1442,14 @@ int kvm_init(void) nc++; } - s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0); + do { + s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0); + } while (s->vmfd < 0 && (-EINTR == s->vmfd || -EAGAIN == s->vmfd)); + if (s->vmfd < 0) { + fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -s->vmfd, + strerror(-s->vmfd)); + #ifdef TARGET_S390X fprintf(stderr, "Please add the 'switch_amode' kernel parameter to " "your host kernel command line\n"); -- 1.8.5.1