diff mbox

[2/2] kvm tool: Close kernel FD after loading it into memory

Message ID 1302345496-20669-2-git-send-email-levinsasha928@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sasha Levin April 9, 2011, 10:38 a.m. UTC
Once the kernel has been loaded into the guest memory, close the FD of the file.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/kvm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Comments

Pekka Enberg April 9, 2011, 11:27 a.m. UTC | #1
On Sat, 9 Apr 2011, Sasha Levin wrote:
> Once the kernel has been loaded into the guest memory, close the FD of the file.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
> 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)

These checks are not needed. I cleaned those up and applied the patch. 
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;
 }