public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: mingo@elte.hu, kvm@vger.kernel.org, penberg@kernel.org,
	asias.hejun@gmail.com, gorcunov@gmail.com,
	chaitanyakulkarni15@gmail.com, ashwini.kulkarni@gmail.com
Subject: Re: [PATCH v2 2/4] kvm tools: Close the disk images after the guest shuts down
Date: Fri, 20 May 2011 18:29:25 +0300	[thread overview]
Message-ID: <1305905365.3205.20.camel@lappy> (raw)
In-Reply-To: <1305903760-7804-2-git-send-email-prasadjoshi124@gmail.com>

On Fri, 2011-05-20 at 16:02 +0100, Prasad Joshi wrote:
> Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
> ---
>  tools/kvm/disk/core.c              |    8 ++++++++
>  tools/kvm/include/kvm/disk-image.h |    1 +
>  tools/kvm/kvm-run.c                |    1 +
>  3 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
> index c53944f..155c95e 100644
> --- a/tools/kvm/disk/core.c
> +++ b/tools/kvm/disk/core.c
> @@ -114,6 +114,14 @@ int disk_image__close(struct disk_image *disk)
>  	return 0;
>  }
>  
> +void disk_image__close_all(struct disk_image **disks, int count)
> +{

It's worth adding a small 'if (count > 0)' since this function is
currently called unconditionally.
No one assures we'll always have a default image.

> +	while (--count)
> +		disk_image__close(disks[count]);
> +
> +	free(disks);
> +}
> +
>  /*
>   * Fill iov with disk data, starting from sector 'sector'.
>   * Return amount of bytes read.
> diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h
> index bf2bfa9..1363fe1 100644
> --- a/tools/kvm/include/kvm/disk-image.h
> +++ b/tools/kvm/include/kvm/disk-image.h
> @@ -55,6 +55,7 @@ struct disk_image *disk_image__open(const char *filename, bool readonly);
>  struct disk_image **disk_image__open_all(const char **filenames, bool *readonly, int count);
>  struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops, int mmap);
>  int disk_image__close(struct disk_image *disk);
> +void disk_image__close_all(struct disk_image **disks, int count);
>  int disk_image__flush(struct disk_image *disk);
>  ssize_t disk_image__read(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
>  ssize_t disk_image__write(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
> index e16caac..9bfe8fe 100644
> --- a/tools/kvm/kvm-run.c
> +++ b/tools/kvm/kvm-run.c
> @@ -615,6 +615,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  			exit_code = 1;
>  	}
>  
> +	disk_image__close_all(kvm->disks, image_count);
>  	kvm__delete(kvm);
>  
>  	if (!exit_code)

-- 

Sasha.


  reply	other threads:[~2011-05-20 15:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 15:02 [PATCH v2 1/4] kvm tools: Add a wrapper function to open disk images Prasad Joshi
2011-05-20 15:02 ` [PATCH v2 2/4] kvm tools: Close the disk images after the guest shuts down Prasad Joshi
2011-05-20 15:29   ` Sasha Levin [this message]
2011-05-20 15:02 ` [PATCH v2 3/4] kvm tools: Add a wrapper function to initialize all virtio block devices Prasad Joshi
2011-05-20 15:02 ` [PATCH v2 4/4] kvm tools: Release memory allocated during virtio block initialization Prasad Joshi
2011-05-20 15:28 ` [PATCH v2 1/4] kvm tools: Add a wrapper function to open disk images Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305905365.3205.20.camel@lappy \
    --to=levinsasha928@gmail.com \
    --cc=ashwini.kulkarni@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=chaitanyakulkarni15@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox