From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH v1 1/3] kvm tools: Close the disk images after the guest shuts down Date: Wed, 18 May 2011 13:31:47 +0300 Message-ID: <1305714707.12150.74.camel@sasha> References: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 To: Prasad Joshi Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:52150 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755924Ab1ERKbw (ORCPT ); Wed, 18 May 2011 06:31:52 -0400 Received: by wwa36 with SMTP id 36so1553026wwa.1 for ; Wed, 18 May 2011 03:31:51 -0700 (PDT) In-Reply-To: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 2011-05-18 at 11:17 +0100, Prasad Joshi wrote: > Signed-off-by: Prasad Joshi > --- > tools/kvm/kvm-run.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c > index ba8e5ce..ef180e4 100644 > --- a/tools/kvm/kvm-run.c > +++ b/tools/kvm/kvm-run.c > @@ -46,6 +46,7 @@ > #define MAX_DISK_IMAGES 4 > > static struct kvm *kvm; > +static struct disk_image *image_disks[MAX_DISK_IMAGES]; You already have image_filename[] which holds image filenames, and image_count which tells you how many images are loaded. > static struct kvm_cpu *kvm_cpus[KVM_NR_CPUS]; > static __thread struct kvm_cpu *current_kvm_cpu; > > @@ -504,6 +505,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) > die("unable to load disk image %s", image_filename[i]); > > virtio_blk__init(kvm, disk); > + image_disks[i] = disk; > } > } > free(hi); > @@ -583,6 +585,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) > exit_code = 1; > } > > + for (i = 0; i < MAX_DISK_IMAGES; i++) { > + if (image_disks[i]) > + disk_image__close(image_disks[i]); > + } > + > kvm__delete(kvm); > > if (!exit_code) -- Sasha.