From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: Devin Nakamura Date: Fri, 29 Jul 2011 00:49:52 -0400 Message-Id: <1311914994-20482-23-git-send-email-devin122@gmail.com> In-Reply-To: <1311914994-20482-1-git-send-email-devin122@gmail.com> References: <1311914994-20482-1-git-send-email-devin122@gmail.com> Subject: [Qemu-devel] [RFC 22/24] qemu-io: make map command use new block mapping function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Devin Nakamura 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, -- 1.7.6.rc1