Convert DPRINTF() to trace event
PATCH 1/1 Convert DPRINTF() to trace event
From: Halloween <[email protected]>
--- hw/virtio/trace-events | 12 ++++++++++++ hw/virtio/virtio-crypto.c | 29 ++++++++++++++++------------- include/hw/virtio/virtio-crypto.h | 11 ----------- 3 files changed, 28 insertions(+), 24 deletions(-)
hw/virtio/trace-events +12 -0
@@ -73,3 +73,15 @@ virtio_iommu_get_domain(uint32_t domain_id) "Alloc domain=%d" virtio_iommu_put_domain(uint32_t domain_id) "Free domain=%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uint64_t addr) "FAULT reason=%d flags=%d endpoint=%d address =0x%"PRIx64 + +# virtio-crypto.c +virtio_crypto_cipher_session_helper_cipher_alg_and_direction(uint32_t cipher_alg, uint8_t direction) "cipher_alg=%" PRIu32 ", info->direction=%" PRIu32 +virtio_crypto_cipher_session_helper_keylen(uint32_t keylen) "keylen=%" PRIu32 +virtio_crypto_create_sym_session_auth_keylen(uint32_t auth_keylen) "auth_keylen=%" PRIu32 +virtio_crypto_create_sym_session_session_id(int64_t session_id) "create session_id=%" PRIu64 " successfully" +virtio_crypto_sym_op_helper_src_len(uint32_t src_len) "src_len=%" PRIu32 +virtio_crypto_sym_op_helper_dst_len(uint32_t dst_len) "dst_len=%" PRIu32 +virtio_crypto_sym_op_helper_hash_result_len(uint32_t hash_result_len) "hash_result_len=%" PRIu32 +virtio_crypto_handle_close_session(uint64_t session_id) "close session id %" PRIu64 +virtio_crypto_sym_op_helper_iv_len(uint32_t iv_len) "iv_len %" PRIu32 +virtio_crypto_sym_op_helper_aad_len(uint32_t aad_len) "aad_len %" PRIu32
hw/virtio/virtio-crypto.c +16 -13
@@ -25,6 +25,8 @@#include "standard-headers/linux/virtio_ids.h" #include "sysemu/cryptodev-vhost.h" +#include "trace.h" +#define VIRTIO_CRYPTO_VM_VERSION 1/*
@@ -49,8 +51,8 @@ virtio_crypto_cipher_session_helper(VirtIODevice *vdev, info->cipher_alg =ldl_le_p (&cipher_para->algo); info->key_len =ldl_le_p (&cipher_para->keylen); info->direction =ldl_le_p (&cipher_para->op); -DPRINTF ("cipher_alg=%" PRIu32", info->direction=%" PRIu32"\n" , - info->cipher_alg, info->direction); +trace_virtio_crypto_cipher_session_helper_cipher_alg_and_direction (\ + info->cipher_alg, info->direction);if (info->key_len > vcrypto->conf.max_cipher_key_len) { error_report("virtio-crypto length of cipher key is too big: %u",
@@ -60,7 +62,7 @@ virtio_crypto_cipher_session_helper(VirtIODevice *vdev,/* Get cipher key */ if (info->key_len >0 ) {size_t s; -DPRINTF ("keylen=%" PRIu32"\n" , info->key_len); +trace_virtio_crypto_cipher_session_helper_keylen (info->key_len); info->cipher_key =g_malloc (info->key_len); s =iov_to_buf (*iov, num,0 , info->cipher_key, info->key_len);
@@ -130,7 +132,9 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, }/* get auth key */ if (info.auth_key_len >0 ) { -DPRINTF ("auth_keylen=%" PRIu32"\n" , info.auth_key_len); +trace_virtio_crypto_create_sym_session_auth_keylen (\ + info.auth_key_len); + info.auth_key =g_malloc (info.auth_key_len); s =iov_to_buf (iov, out_num,0 , info.auth_key, info.auth_key_len);
@@ -165,9 +169,7 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, vcrypto->cryptodev, &info, queue_index, &local_err);if (session_id >=0 ) { -DPRINTF ("create session_id=%" PRIu64" successfully\n" , - session_id); - +trace_virtio_crypto_create_sym_session_session_id (session_id); ret = session_id; }else {if (local_err) {
@@ -193,7 +195,7 @@ virtio_crypto_handle_close_session(VirtIOCrypto *vcrypto,Error *local_err =NULL ; session_id =ldq_le_p (&close_sess_req->session_id); -DPRINTF ("close session, id=%" PRIu64"\n" , session_id); +trace_virtio_crypto_handle_close_session (session_id); ret =cryptodev_backend_sym_close_session ( vcrypto->cryptodev, session_id, queue_id, &local_err);
@@ -474,7 +476,8 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, op_info->len_to_cipher = len_to_cipher;/* Handle the initilization vector */ if (op_info->iv_len >0 ) { -DPRINTF ("iv_len=%" PRIu32"\n" , op_info->iv_len); +trace_virtio_crypto_sym_op_helper_iv_len (op_info->iv_len); + op_info->iv = op_info->data + curr_size; s =iov_to_buf (iov, out_num,0 , op_info->iv, op_info->iv_len);
@@ -488,7 +491,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev,/* Handle additional authentication data if exists */ if (op_info->aad_len >0 ) { -DPRINTF ("aad_len=%" PRIu32"\n" , op_info->aad_len); +trace_virtio_crypto_sym_op_helper_aad_len (op_info->aad_len); op_info->aad_data = op_info->data + curr_size; s =iov_to_buf (iov, out_num,0 , op_info->aad_data, op_info->aad_len);
@@ -503,7 +506,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev,/* Handle the source data */ if (op_info->src_len >0 ) { -DPRINTF ("src_len=%" PRIu32"\n" , op_info->src_len); +trace_virtio_crypto_sym_op_helper_src_len (op_info->src_len); op_info->src = op_info->data + curr_size; s =iov_to_buf (iov, out_num,0 , op_info->src, op_info->src_len);
@@ -520,11 +523,11 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, op_info->dst = op_info->data + curr_size; curr_size += op_info->dst_len; -DPRINTF ("dst_len=%" PRIu32"\n" , op_info->dst_len); +trace_virtio_crypto_sym_op_helper_dst_len (op_info->dst_len);/* Handle the hash digest result */ if (hash_result_len >0 ) { -DPRINTF ("hash_result_len=%" PRIu32"\n" , hash_result_len); +trace_virtio_crypto_sym_op_helper_hash_result_len (hash_result_len); op_info->digest_result = op_info->data + curr_size; }
include/hw/virtio/virtio-crypto.h +0 -11
@@ -19,17 +19,6 @@#include "sysemu/iothread.h" #include "sysemu/cryptodev.h" - -#define DEBUG_VIRTIO_CRYPTO 0 - -#define DPRINTF (fmt, ...) \ -do { \ - if (DEBUG_VIRTIO_CRYPTO) { \ - fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \ - } \ -} while (0) - -#define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"#define VIRTIO_CRYPTO (obj) \ OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO)
Signature · 1 line
2.17.1
Quoted 3 lines · teachk
From: Halloween <[email protected]>
Signed-off-by Halloween <[email protected]>
Thanks for this submission. However, we prefer that you use a legal name for your authorship and signed-off-by tag rather than a pseudonym. https://wiki.qemu.org/Contribute/SubmitAPatch explains:
"You must provide a Signed-off-by: line (this is a hard requirement because it's how you say "I'm legally okay to contribute this and happy for it to go into QEMU", modeled after the Linux kernel policy.)"
and Linux states:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297
"using your real name (sorry, no pseudonyms or anonymous contributions.)"
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org