All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: "Tan, Li" <li.tan@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] [RFC][PATCH] kvm: kvmtrace: kvmtrace_format for supporting big_endian
Date: Tue, 20 May 2008 19:22:44 +0300	[thread overview]
Message-ID: <4832FAD4.2040908@qumranet.com> (raw)
In-Reply-To: <08DF4D958216244799FC84F3514D70F00164BF20@pdsmsx415.ccr.corp.intel.com>

Tan, Li wrote:
> From 9d39264bdfb00a1a717074e486a948a578547c50 Mon Sep 17 00:00:00 2001
> From: Tan Li <li.tan@intel.com>
> Date: Tue, 20 May 2008 09:14:41 +0800
> Subject: [PATCH] [RFC][PATCH] kvm: kvmtrace: kvmtrace_format for
> supporting big_endian
>
> Currently kvmtrace is not portable, and prevent from copying a trace
> file from big-endian target to little-endian workstation for analysis.
>
> In the patch, kvmtrace_format reads and checks the magic number from
> trace log. if needed, then change bytes order of all fields in records
> followed.
>
>  
> +def reverse_bytes(origin, bytes_cnt):
> +	i = 0
> +	rtn = 0L
> +	while i < bytes_cnt:
> +		i = i + 1
> +	        b = origin & 0xff
> +		origin = origin >> 8
> +		rtn = (rtn << 8) + b
> +	return rtn
> +
> +def reverse_int(origin):
> +	return reverse_bytes(origin, 4)
> +
> +def reverse_qword(origin):
> +	return reverse_bytes(origin, 8)
> +
>  def sighand(x,y):
>      global interrupted
>      interrupted = 1
> @@ -100,18 +116,40 @@ D2REC  = "II"
>  D3REC  = "III"
>  D4REC  = "IIII"
>  D5REC  = "IIIII"
> +KMAGIC  = "I"
>   

The python struct module supports reading big-endian and little-endian 
data.  So you can simply switch the format strings if you have the wrong 
endianness.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2008-05-20 16:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <08DF4D958216244799FC84F3514D70F0015B1B58@pdsmsx415.ccr.corp.intel.com>
2008-05-14 21:37 ` [kvm-ppc-devel] kvm trace support for ppc Hollis Blanchard
2008-05-14 21:37   ` Hollis Blanchard
2008-05-15  1:20   ` [kvm-ppc-devel] " Tan, Li
2008-05-15  1:20     ` Tan, Li
2008-05-16  6:26   ` [kvm-ppc-devel] " Tan, Li
2008-05-16  6:26     ` Tan, Li
2008-05-20  6:53   ` [PATCH] [RFC][PATCH] kvm: kvmtrace: kvm_trace in kernel for supporting big_endian Tan, Li
2008-05-20  7:03     ` [PATCH] [RFC][PATCH] kvm: kvmtrace: kvmtrace_format " Tan, Li
2008-05-20 16:22       ` Avi Kivity [this message]
2008-05-21  7:36         ` Tan, Li
2008-05-21  9:21           ` Avi Kivity
2008-05-22  0:30             ` Tan, Li
2008-05-25  9:34               ` Avi Kivity
2008-05-26  5:38                 ` Tan, Li
2008-05-28 11:17                   ` Avi Kivity
2008-06-02  1:25                     ` Tan, Li
2008-05-20 16:25     ` [PATCH] [RFC][PATCH] kvm: kvmtrace: kvm_trace in kernel " Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4832FAD4.2040908@qumranet.com \
    --to=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    --cc=li.tan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.