From patchwork Wed Apr 13 17:36:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Joshi X-Patchwork-Id: 705441 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3DHaPAi012562 for ; Wed, 13 Apr 2011 17:36:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752502Ab1DMRgU (ORCPT ); Wed, 13 Apr 2011 13:36:20 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:50057 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096Ab1DMRgS (ORCPT ); Wed, 13 Apr 2011 13:36:18 -0400 Received: by wya21 with SMTP id 21so706651wya.19 for ; Wed, 13 Apr 2011 10:36:17 -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=lFVx3hfIpru+VXi3JsW+nyRxidL/pldun5wNHm5rQ2I=; b=X3NrZNrrHee8bEdTzpfBGK9sxioHoQejE/1jWPS8FuSa/XTeWnhxWG4zDUzyHW1Ptl hPRLIs5WtoWZT+KaeAlAALtUm2ptYfExnUQF3dyMuoeCTvSLOsRgqYefoVZZtpgweJV7 tazD5La4DG2PVGIjEwF3JsJUSJ1J6t4OEwhUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=VISfzHYkdO97xWZXk8nZ3AmEPxecBpvtiAcZLV7GC2onBY0P9I8mtzrd2wAp/WzOsr sOhASXI80ifOR1WMJA33Wjl1AeGmQy+yJKr++G4EK4QQ+LVjt70TC2TqyuJ3mlrsVKjj D/wCLoM97qd5U2RE4MlkSQabpyQvb4LK1OD4w= Received: by 10.227.98.9 with SMTP id o9mr8086396wbn.25.1302716177467; Wed, 13 Apr 2011 10:36:17 -0700 (PDT) Received: from prasad-kvm.localdomain (pineapple.rdg.ac.uk [134.225.206.123]) by mx.google.com with ESMTPS id o6sm478641wbo.37.2011.04.13.10.36.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2011 10:36:16 -0700 (PDT) Received: by prasad-kvm.localdomain (Postfix, from userid 1000) id 6CF5A26E006E; Wed, 13 Apr 2011 18:36:22 +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 Subject: [PATCH] kvm tool: add a close method for raw_image_ro_mmap_ops Date: Wed, 13 Apr 2011 18:36:21 +0100 Message-Id: <1302716181-13730-1-git-send-email-prasadjoshi124@gmail.com> X-Mailer: git-send-email 1.7.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 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Apr 2011 17:36:26 +0000 (UTC) --- tools/kvm/disk-image.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/kvm/disk-image.c b/tools/kvm/disk-image.c index c666c04..df7dd48 100644 --- a/tools/kvm/disk-image.c +++ b/tools/kvm/disk-image.c @@ -92,6 +92,13 @@ static int raw_image__write_sector_ro_mmap(struct disk_image *self, uint64_t sec return 0; } +static void raw_image__close_sector_ro_mmap(struct disk_image *self) +{ + if (self->priv != MAP_FAILED) + munmap(self->priv, self->size); +} + + static struct disk_image_operations raw_image_ops = { .read_sector = raw_image__read_sector, .write_sector = raw_image__write_sector, @@ -100,6 +107,7 @@ static struct disk_image_operations raw_image_ops = { static struct disk_image_operations raw_image_ro_mmap_ops = { .read_sector = raw_image__read_sector_ro_mmap, .write_sector = raw_image__write_sector_ro_mmap, + .close = raw_image__close_sector_ro_mmap, }; static struct disk_image *raw_image__probe(int fd, bool readonly) @@ -140,9 +148,6 @@ void disk_image__close(struct disk_image *self) if (!self) return; - if (self->priv != MAP_FAILED) - munmap(self->priv, self->size); - if (self->ops->close) self->ops->close(self);