blob: 452c7f589d3ee1ae76716ffe2c94e4ae4820cc5e [file] [log] [blame]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Generic management for the 'vcpu' property.
__author__ = "Lluís Vilanova <>"
__copyright__ = "Copyright 2016, Lluís Vilanova <>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
__email__ = ""
from tracetool import Arguments, try_import
def transform_event(event):
"""Transform event to comply with the 'vcpu' property (if present)."""
if "vcpu" in
# events with 'tcg-trans' and 'tcg-exec' are auto-generated from
# already-patched events
assert "tcg-trans" not in
assert "tcg-exec" not in
event.args = Arguments([("CPUState *", "__cpu"), event.args])
if "tcg" in
fmt = "\"cpu=%p \""
event.fmt = [fmt + event.fmt[0],
fmt + event.fmt[1]]
fmt = "\"cpu=%p \""
event.fmt = fmt + event.fmt
return event
def transform_args(format, event, *args, **kwargs):
"""Transforms the arguments to suit the specified format.
The format module must implement function 'vcpu_args', which receives the
implicit arguments added by the 'vcpu' property, and must return suitable
arguments for the given format.
The function is only called for events with the 'vcpu' property.
format : str
Format module name.
event : Event
args, kwargs
Passed to 'vcpu_transform_args'.
The transformed arguments, including the non-implicit ones.
if "vcpu" in
ok, func = try_import("tracetool.format." + format,
assert ok
assert func
return Arguments([func(event.args[:1], *args, **kwargs),
return event.args