From patchwork Wed Oct 26 10:19:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu He Jie X-Patchwork-Id: 121872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CF84B1007D9 for ; Wed, 26 Oct 2011 21:21:17 +1100 (EST) Received: from localhost ([::1]:44649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ0bf-0005im-Ew for incoming@patchwork.ozlabs.org; Wed, 26 Oct 2011 06:21:11 -0400 Received: from eggs.gnu.org ([140.186.70.92]:33287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ0bZ-0005iS-MD for qemu-devel@nongnu.org; Wed, 26 Oct 2011 06:21:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJ0bY-0007Gg-Aj for qemu-devel@nongnu.org; Wed, 26 Oct 2011 06:21:05 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:51980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ0bX-0007Fr-LD for qemu-devel@nongnu.org; Wed, 26 Oct 2011 06:21:04 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp06.au.ibm.com (8.14.4/8.13.1) with ESMTP id p9QAJQX7014704 for ; Wed, 26 Oct 2011 21:19:26 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9QAHwf62129964 for ; Wed, 26 Oct 2011 21:18:00 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9QAKeAV010403 for ; Wed, 26 Oct 2011 21:20:40 +1100 Received: from soulxu-ThinkPad-T410.cn.ibm.com ([9.115.122.84]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9QAKd3d008007; Wed, 26 Oct 2011 21:20:39 +1100 From: Xu He Jie To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2011 18:19:47 +0800 Message-Id: <1319624387-15707-1-git-send-email-xuhj@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 202.81.31.148 Cc: Xu He Jie Subject: [Qemu-devel] [PATCH] kvm_init didn't set return value after create vm failed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org kvm_init didn't set return value after create vm failed. And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1, so change the check of vmfd at label 'err'. Signed-off-by: Xu He Jie --- kvm-all.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index e7faf5c..70edb39 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -739,6 +739,7 @@ int kvm_init(void) fprintf(stderr, "Please add the 'switch_amode' kernel parameter to " "your host kernel command line\n"); #endif + ret = -errno; goto err; } @@ -797,7 +798,7 @@ int kvm_init(void) err: if (s) { - if (s->vmfd != -1) { + if (s->vmfd >= 0) { close(s->vmfd); } if (s->fd != -1) {