From: Hyman Huang(黄勇) <huang...@chinatelecom.cn> Introduce "info netdev" command so developers can play with it easier.
Signed-off-by: Hyman Huang(黄勇) <huang...@chinatelecom.cn> --- hmp-commands-info.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + net/net.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 754b1e8..217843c 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -880,6 +880,20 @@ SRST Display the vcpu dirty page limit information. ERST + { + .name = "netdev", + .args_type = "", + .params = "", + .help = "show information about netdev, guest acked features are " + "also printed if supporting virtio-net dataplane offloading", + .cmd = hmp_info_netdev, + }, + +SRST + ``info netdev`` + Display information about netdev. +ERST + #if defined(TARGET_I386) { .name = "sgx", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index a9cf064..0bd496a 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -142,5 +142,6 @@ void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); void hmp_human_readable_text_helper(Monitor *mon, HumanReadableText *(*qmp_handler)(Error **)); void hmp_info_stats(Monitor *mon, const QDict *qdict); +void hmp_info_netdev(Monitor *mon, const QDict *qdict); #endif diff --git a/net/net.c b/net/net.c index 5d11674..c27ebfa 100644 --- a/net/net.c +++ b/net/net.c @@ -55,6 +55,7 @@ #include "net/filter.h" #include "net/vhost-user.h" #include "qapi/string-output-visitor.h" +#include "monitor/hmp.h" /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -1268,6 +1269,36 @@ NetDevInfoList *qmp_query_netdev(Error **errp) return head; } +void hmp_info_netdev(Monitor *mon, const QDict *qdict) +{ + NetDevInfoList *info, *head, *info_list = NULL; + Error *err = NULL; + + info_list = qmp_query_netdev(&err); + if (err) { + hmp_handle_error(mon, err); + return; + } + + head = info_list; + for (info = head; info != NULL; info = info->next) { + monitor_printf(mon, "%s: %s device, " + "ufo %s, vnet-hdr %s, vnet-hdr-len %s", + info->value->name, + NetClientDriver_str(info->value->type), + info->value->ufo ? "supported" : "unsupported", + info->value->vnet_hdr ? "supported" : "unsupported", + info->value->vnet_hdr_len ? "supported" : "unsupported"); + if (info->value->has_acked_features) { + monitor_printf(mon, ", acked-features 0x%" PRIx64, + info->value->acked_features); + } + monitor_printf(mon, "\n"); + } + + g_free(info_list); +} + static void netfilter_print_info(Monitor *mon, NetFilterState *nf) { char *str; -- 1.8.3.1