From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: Sanidhya Kashyap Date: Fri, 1 Aug 2014 08:42:31 +0530 Message-Id: <1406862751-24008-7-git-send-email-sanidhya.iiith@gmail.com> In-Reply-To: <1406862751-24008-1-git-send-email-sanidhya.iiith@gmail.com> References: <1406862751-24008-1-git-send-email-sanidhya.iiith@gmail.com> Subject: [Qemu-devel] [PATCH v5 6/6] BitmapLog: python script for extracting bitmap from a binary file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu list Cc: Sanidhya Kashyap , "Dr. David Alan Gilbert" , Juan Quintela 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('