From patchwork Wed May 18 10:17:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Joshi X-Patchwork-Id: 793312 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 p4IAMV8H029441 for ; Wed, 18 May 2011 10:22:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756890Ab1ERKRZ (ORCPT ); Wed, 18 May 2011 06:17:25 -0400 Received: from mail-ww0-f42.google.com ([74.125.82.42]:50748 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755328Ab1ERKRW (ORCPT ); Wed, 18 May 2011 06:17:22 -0400 Received: by wwk4 with SMTP id 4so4455358wwk.1 for ; Wed, 18 May 2011 03:17:21 -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; bh=Jfwg4fp/KSfwjQfjx0TbjO7U1E1LABfyKuATMDKW5CY=; b=kRRJUwuPBgHq4obhDXIpgPVec9unrbbk2aKFb/c0O0pcVkZJZXu/mEeuXWpCaZDY8V HFkFQw5Pn7kNToGGtWaK+5X7FOiwiAtzjG3Cw7GQtwr/ByRi7YxlzZ2bliSZV3pUYCkf KW7qrpw9md4AgY+1hKgJzcaPwo5lPjRr1/4N8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=lzx3DfZb3urniju/Yx44PBEpTwKwVw4WIZyAq1L5j/g+R1wHE/yWZ1hNGl/dHqzlyy 71R1HV8LSO7/TK9qHAlgyWvMF8+eCIDXOWuGe9UTvlOT/6Cv9gPTkL5+Y+s0IlZa+6mY T1gtCyMjRnQ0kzvaXe1az67pDA5HBB5MQuUUA= Received: by 10.216.150.153 with SMTP id z25mr1596649wej.89.1305713840483; Wed, 18 May 2011 03:17:20 -0700 (PDT) Received: from prasad-kvm.localdomain (pineapple.rdg.ac.uk [134.225.206.123]) by mx.google.com with ESMTPS id o6sm707986wep.41.2011.05.18.03.17.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 03:17:19 -0700 (PDT) Received: by prasad-kvm.localdomain (Postfix, from userid 1000) id D68DC26E004E; Wed, 18 May 2011 11:17:18 +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 v1 1/3] kvm tools: Close the disk images after the guest shuts down Date: Wed, 18 May 2011 11:17:15 +0100 Message-Id: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com> X-Mailer: git-send-email 1.7.4.1 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]); Wed, 18 May 2011 10:22:32 +0000 (UTC) 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]; 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)