From patchwork Sat Apr 9 10:38:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 695801 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p39Acp03028459 for ; Sat, 9 Apr 2011 10:38:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168Ab1DIKir (ORCPT ); Sat, 9 Apr 2011 06:38:47 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:52504 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754030Ab1DIKiq (ORCPT ); Sat, 9 Apr 2011 06:38:46 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so3695295wya.19 for ; Sat, 09 Apr 2011 03:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=LNWNme91bRuhdMq9inBP1uV1gEB9r9uTTkhpAHflmQ0=; b=wisevBI16dzdsYA1b1OOjT6wf/zeLnh5L6l/OsI5jWPcf2TKI6al7vxxhjXXTKW6T6 mRLZfIjUYNauljtkntt60zTXQqQ4ykTrfxbYwRkP4W+ZUGsRRkI6IJf0mPUuZN2+sCvI 16Z61e+3RDHYNr04MfHlKe2RhB966Ohp6Ewyc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Pjt6tQY7PWpD66giwjV76b/Y35r6qrf0GIjP8MzzNCnEQtYa7mWanI10NKYd0I9EbP Bv6zc47cpuIMUxoZM46mj05HgyKuXVCnrHl7ce4VaW4G67Wng/TCPkMC4lEAn2Iz2DSv TIIlV6r/1N73cc9zxBFuFyo698EQC9Gj3nxEg= Received: by 10.216.3.200 with SMTP id 50mr723186weh.34.1302345525619; Sat, 09 Apr 2011 03:38:45 -0700 (PDT) Received: from localhost.localdomain ([94.230.80.142]) by mx.google.com with ESMTPS id g32sm1731531wej.27.2011.04.09.03.38.44 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 09 Apr 2011 03:38:45 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 2/2] kvm tool: Close kernel FD after loading it into memory Date: Sat, 9 Apr 2011 13:38:16 +0300 Message-Id: <1302345496-20669-2-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc1 In-Reply-To: <1302345496-20669-1-git-send-email-levinsasha928@gmail.com> References: <1302345496-20669-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 09 Apr 2011 10:38:51 +0000 (UTC) Once the kernel has been loaded into the guest memory, close the FD of the file. Signed-off-by: Sasha Levin --- tools/kvm/kvm.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index af1f65f..5027a0d 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -385,9 +385,15 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename, if (ret) goto found_kernel; + if (fd_kernel >= 0) + close(fd_kernel); + die("%s is not a valid bzImage or flat binary", kernel_filename); found_kernel: + if (fd_kernel >= 0) + close(fd_kernel); + return ret; }