From patchwork Fri Jul 29 04:49:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Nakamura X-Patchwork-Id: 107347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BDDDCB6F68 for ; Fri, 29 Jul 2011 15:44:35 +1000 (EST) Received: from localhost ([::1]:37650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf37-0004dZ-Qa for incoming@patchwork.ozlabs.org; Fri, 29 Jul 2011 00:51:49 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf28-0002jM-K8 for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmf23-0000TP-Kt for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:48 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:46817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf23-0000NN-EI for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:43 -0400 Received: by mail-iy0-f173.google.com with SMTP id 39so4186308iyb.4 for ; Thu, 28 Jul 2011 21:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=VqGUuNStWZYNvMtk7CQ4nOd9ihGQhyuR2nTcNergfvY=; b=xvTv2/abrTGBR62O7WhmvwSm/AGn9GAhsDC5WTWTpc+4bhq8uyJ3dwESNmKH8zc/rl FQ8c1ZqS9SzsRfU5eoruke/tJ7j+Mzyyga8KmYO6YaWLvyrrBlVzpjFEc06oTeJ4903k cFUIP/fAhuJDXD0pH9HXEnNWa5WrqlVjDlXwc= Received: by 10.231.92.132 with SMTP id r4mr581285ibm.65.1311915043130; Thu, 28 Jul 2011 21:50:43 -0700 (PDT) Received: from localhost.localdomain (d72-39-252-38.home1.cgocable.net [72.39.252.38]) by mx.google.com with ESMTPS id v16sm1109424ibf.25.2011.07.28.21.50.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 21:50:42 -0700 (PDT) From: Devin Nakamura To: qemu-devel@nongnu.org Date: Fri, 29 Jul 2011 00:49:52 -0400 Message-Id: <1311914994-20482-23-git-send-email-devin122@gmail.com> X-Mailer: git-send-email 1.7.6.rc1 In-Reply-To: <1311914994-20482-1-git-send-email-devin122@gmail.com> References: <1311914994-20482-1-git-send-email-devin122@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.173 Cc: kwolf@redhat.com, Devin Nakamura Subject: [Qemu-devel] [RFC 22/24] qemu-io: make map command use new block mapping function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org bdrv_get_mapping will be used when it is defined, otherwise default to old behaviour. Signed-off-by: Devin Nakamura --- qemu-io.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index a553d0c..caf51fe 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1543,7 +1543,7 @@ static const cmdinfo_t alloc_cmd = { .oneline = "checks if a sector is present in the file", }; -static int map_f(int argc, char **argv) +static int map_f_old(int argc, char **argv) { int64_t offset; int64_t nb_sectors; @@ -1570,6 +1570,27 @@ static int map_f(int argc, char **argv) return 0; } +static int map_f(int argc, char **argv) +{ + uint64_t host_offset, guest_offset, count; + int ret; + + if (!bs->drv->bdrv_get_mapping) { + return map_f_old(argc, argv); + } + + guest_offset = count = 0; + printf(" Guest Offset - Host Offset - Count\n"); + do { + ret = bdrv_get_mapping(bs, &guest_offset, &host_offset, &count); + if (count) { + printf("%016lx - %016lx - %016lx\n", guest_offset, host_offset, + count); + } + } while (!ret && count > 0); + return ret; +} + static const cmdinfo_t map_cmd = { .name = "map", .argmin = 0,