From patchwork Fri May 20 15:02:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Joshi X-Patchwork-Id: 803892 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4KF3NPW028046 for ; Fri, 20 May 2011 15:03:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756864Ab1ETPDU (ORCPT ); Fri, 20 May 2011 11:03:20 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:60808 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756735Ab1ETPDT (ORCPT ); Fri, 20 May 2011 11:03:19 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so4116827wwa.1 for ; Fri, 20 May 2011 08:03:19 -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=VwCWlcdyfjvTsfvrXPuflLkL3P7aiBCC03jm/hLd5mc=; b=wr0bIN5UPHQC+BkBpRwgDL++gQ2c4D10AgIH0+cLTfnDSdAIpuw05PU3nGvwoAamdg vEmnIHQiuoy7s1reGNxPE44U8JzoaJMoTMoKYgRiugXsVeba/YHjE5Mh+vGNatVmE2Js WCbtpV2ygSA3XPCp4rRuyDTNAawmGK+bhbCTA= 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=riw7fCPoDBbSadq7HGsm0iJTxasm1unzXk7DR3eDcp2eKqnohoEeLepptc5oRO68ql K01vCTL+ls5QdBnLj7eDksp4rligx9JseRyNzO3Han6nBZtDNhoAROWNvNtHcdTs4KAp jnEkjcBBLxzNXyq2n1Y9pRM6gRU9Jb8QiwWw4= Received: by 10.216.139.209 with SMTP id c59mr4123083wej.88.1305903799084; Fri, 20 May 2011 08:03:19 -0700 (PDT) Received: from prasad-kvm.localdomain (pineapple.rdg.ac.uk [134.225.206.123]) by mx.google.com with ESMTPS id k76sm1893470wej.43.2011.05.20.08.02.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2011 08:02:54 -0700 (PDT) Received: by prasad-kvm.localdomain (Postfix, from userid 1000) id 23A8426E004C; Fri, 20 May 2011 16:02:40 +0100 (BST) From: Prasad Joshi To: prasadjoshi124@gmail.com Cc: mingo@elte.hu, kvm@vger.kernel.org, penberg@kernel.org, asias.hejun@gmail.com, gorcunov@gmail.com, levinsasha928@gmail.com, chaitanyakulkarni15@gmail.com, ashwini.kulkarni@gmail.com Subject: [PATCH v2 2/4] kvm tools: Close the disk images after the guest shuts down Date: Fri, 20 May 2011 16:02:38 +0100 Message-Id: <1305903760-7804-2-git-send-email-prasadjoshi124@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1305903760-7804-1-git-send-email-prasadjoshi124@gmail.com> References: <1305903760-7804-1-git-send-email-prasadjoshi124@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 (demeter2.kernel.org [140.211.167.43]); Fri, 20 May 2011 15:03:23 +0000 (UTC) Signed-off-by: Prasad Joshi --- 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) +{ + 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)