From patchwork Fri Aug 1 03:12:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanidhya Kashyap X-Patchwork-Id: 375518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A634B14013E for ; Fri, 1 Aug 2014 13:17:00 +1000 (EST) Received: from localhost ([::1]:59548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD3L0-0003o4-Pu for incoming@patchwork.ozlabs.org; Thu, 31 Jul 2014 23:16:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD3I3-0008Ju-3p for qemu-devel@nongnu.org; Thu, 31 Jul 2014 23:14:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XD3Hw-0000e2-5x for qemu-devel@nongnu.org; Thu, 31 Jul 2014 23:13:55 -0400 Received: from mail-pd0-x22c.google.com ([2607:f8b0:400e:c02::22c]:33355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD3Hv-0000dU-QG for qemu-devel@nongnu.org; Thu, 31 Jul 2014 23:13:48 -0400 Received: by mail-pd0-f172.google.com with SMTP id ft15so4666269pdb.17 for ; Thu, 31 Jul 2014 20:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xyifjcMhAUFfuIgKE19zh10kPnguy21UNAphDwn8VSI=; b=wGGnRrTR11HC4A73hCP+GDDZRJ26q6dKqsi1+ElVgdUgjbVYzC6zSFAF4sg5p+o91F 2fCjg9pHtJsH+KogaH/qRHpSLFC2YTGOUf44QtKiNovX/hF5boU7gOtUGYyAfYlYB0YE ByCdeEnWE78Q1TvkiIGUMr5YAwdzi3R/MUCWgLwyHffxm0iRqx+Ocj2wQ/IVD2MnIWZ6 sMWCoWZcEShDhV+HezuuxXQ0/KtthcJ0XoYXIC3SZJeru06KvZQyykyEvKRLX5w2/G2W QhAL9PtJxLAcA+AT5YlztK7TBvuLOquTmxJ5UTNCYkWs1bISSScVIf7nX5Mv31gh3U0B k/lA== X-Received: by 10.70.52.1 with SMTP id p1mr2596995pdo.111.1406862826960; Thu, 31 Jul 2014 20:13:46 -0700 (PDT) Received: from localhost.localdomain ([106.219.174.182]) by mx.google.com with ESMTPSA id u7sm10711518pdj.34.2014.07.31.20.13.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jul 2014 20:13:46 -0700 (PDT) From: Sanidhya Kashyap To: qemu list Date: Fri, 1 Aug 2014 08:42:31 +0530 Message-Id: <1406862751-24008-7-git-send-email-sanidhya.iiith@gmail.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406862751-24008-1-git-send-email-sanidhya.iiith@gmail.com> References: <1406862751-24008-1-git-send-email-sanidhya.iiith@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::22c Cc: Sanidhya Kashyap , "Dr. David Alan Gilbert" , Juan Quintela Subject: [Qemu-devel] [PATCH v5 6/6] BitmapLog: python script for extracting bitmap from a binary file 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 The file not only extracts the bitmap from the file but also draws the figure if required. Currently, figure is drawn for all the bitmaps. Later, I'll make the change to draw for different blocks. The picture is drawn by generating a matrix of 0s and 1s from the bitmap. The dimensions are calculated on the basis of total bitmap pages which is represented as sqrt(total pages) X (sqrt(total pages) + 1). The white parts indicate non dirtied region while the black - dirtied region. The python code requires some libraries such as numpy, pylab and math to generate the images. Signed-off-by: Sanidhya Kashyap --- scripts/extract-bitmap.py | 144 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 scripts/extract-bitmap.py diff --git a/scripts/extract-bitmap.py b/scripts/extract-bitmap.py new file mode 100755 index 0000000..942deca --- /dev/null +++ b/scripts/extract-bitmap.py @@ -0,0 +1,144 @@ +#!/usr/bin/python +# This python script helps in extracting the dirty bitmap present +# in the file after executing the log-dirty-bitmap command either +# from the qmp or hmp interface. This file only processes binary +# file obtained via command. +# +# Copyright (C) 2014 Sanidhya Kashyap +# +# Authors: +# Sanidhya Kashyap +# +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. + +import struct +import argparse +from functools import partial +from math import sqrt +from numpy import array +from pylab import figure,imshow,show,gray + +long_bytes = 8 +byte_size = 8 +int_bytes = 4 +complete_bitmap_list = [] +block_list = [] + +def get_unsigned_long_integer(value): + return struct.unpack('