[PATCH] net: Print the packet size in the debug output

Bin Meng posted 1 patch 4 years, 8 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1614332761-72810-1-git-send-email-bmeng.cn@gmail.com
Maintainers: Jason Wang <jasowang@redhat.com>
net/net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] net: Print the packet size in the debug output
Posted by Bin Meng 4 years, 8 months ago
From: Bin Meng <bin.meng@windriver.com>

Printing out the packet size is helpful during debug.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index 32d71c1..b038370 100644
--- a/net/net.c
+++ b/net/net.c
@@ -641,7 +641,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
     int ret;
 
 #ifdef DEBUG_NET
-    printf("qemu_send_packet_async:\n");
+    printf("qemu_send_packet_async: packet size (%d)\n", size);
     qemu_hexdump(stdout, "net", buf, size);
 #endif
 
-- 
2.7.4


Re: [PATCH] net: Print the packet size in the debug output
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
On 2/26/21 10:46 AM, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> Printing out the packet size is helpful during debug.
> 
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
> 
>  net/net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/net.c b/net/net.c
> index 32d71c1..b038370 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -641,7 +641,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
>      int ret;
>  
>  #ifdef DEBUG_NET
> -    printf("qemu_send_packet_async:\n");
> +    printf("qemu_send_packet_async: packet size (%d)\n", size);
>      qemu_hexdump(stdout, "net", buf, size);

At this point better to convert to trace events (see commit
db1e7afa371):

        if (trace_event_get_state_backends(TRACE_NET_SEND_PACKET)) {
            net_pkt_hexdump(buf, size);
        }