Skip to content

Commit

Permalink
vmsdk/python: update cli for event log
Browse files Browse the repository at this point in the history
* provide extra format option for user to determine the output format
of event logs. Using TCG PCClient by default.

Signed-off-by: Ruoyu Ying <[email protected]>
  • Loading branch information
Ruoyu-y committed Apr 2, 2024
1 parent 95dc2c7 commit 56de7f3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/python/cc_event_log_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import argparse
import os
from cctrusted_base.api import CCTrustedApi
from cctrusted_base.eventlog import TcgEventLog
from cctrusted_base.tcgcel import TcgTpmsCelEvent
from cctrusted_vm.cvm import ConfidentialVM
from cctrusted_vm.sdk import CCTrustedVmSdk

Expand All @@ -28,13 +30,21 @@ def main():
help='index of first event log to fetch', dest='start')
parser.add_argument("-c", type=int, help="number of event logs to fetch",
dest="count")
parser.add_argument("-f", type=bool, help="enable canonical tlv format", default=False,
dest="cel_format")
args = parser.parse_args()

event_logs = CCTrustedVmSdk.inst().get_cc_eventlog(args.start, args.count)
if event_logs is not None:
LOG.info("Total %d of event logs fetched.", len(event_logs))
for event in event_logs:
event.dump()
if isinstance(event, TcgTpmsCelEvent):
if args.cel_format:
TcgTpmsCelEvent.encode(event, TcgEventLog.TCG_FORMAT_CEL_TLV).dump()
else:
event.to_pcclient_format().dump()
else:
event.dump()

if __name__ == "__main__":
main()

0 comments on commit 56de7f3

Please sign in to comment.