2 # -*- coding: utf-8 -*-
5 Generic management for the 'vcpu' property.
9 __author__
= "Lluís Vilanova <vilanova@ac.upc.edu>"
10 __copyright__
= "Copyright 2016, Lluís Vilanova <vilanova@ac.upc.edu>"
11 __license__
= "GPL version 2 or (at your option) any later version"
13 __maintainer__
= "Stefan Hajnoczi"
14 __email__
= "stefanha@linux.vnet.ibm.com"
17 from tracetool
import Arguments
, try_import
20 def transform_event(event
):
21 """Transform event to comply with the 'vcpu' property (if present)."""
22 if "vcpu" in event
.properties
:
23 # events with 'tcg-trans' and 'tcg-exec' are auto-generated from
24 # already-patched events
25 assert "tcg-trans" not in event
.properties
26 assert "tcg-exec" not in event
.properties
28 event
.args
= Arguments([("CPUState *", "__cpu"), event
.args
])
29 if "tcg" in event
.properties
:
31 event
.fmt
= [fmt
+ event
.fmt
[0],
35 event
.fmt
= fmt
+ event
.fmt
39 def transform_args(format
, event
, *args
, **kwargs
):
40 """Transforms the arguments to suit the specified format.
42 The format module must implement function 'vcpu_args', which receives the
43 implicit arguments added by the 'vcpu' property, and must return suitable
44 arguments for the given format.
46 The function is only called for events with the 'vcpu' property.
54 Passed to 'vcpu_transform_args'.
59 The transformed arguments, including the non-implicit ones.
62 if "vcpu" in event
.properties
:
63 ok
, func
= try_import("tracetool.format." + format
,
64 "vcpu_transform_args")
67 return Arguments([func(event
.args
[:1], *args
, **kwargs
),