Export netdev capabilities and information
cover Export netdev capabilities and information
From: Hyman Huang(黄勇) <[email protected]>
This series is enlightened by Michael when we fixed a virtio features negotiation flaw, see the details here:
https://lore.kernel.org/qemu-devel/[email protected]/
And a test is suggested to be added to test behavior of virtio-net features negotiation(if i understand correctly), see the details here:
https://lore.kernel.org/qemu-devel/[email protected]/
Indeed, Qemu does not export interface capabilities such as ufo, vnet-hdr or negotiated features to developers. OVS-DPDK will show the interface status such as features, mode, ring_size and so on if we execute "ovs-vsctl list interface" by comparison. It could be more friendly if we export above capabilities and information for developers, especially for those who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source to DPU-offload destination smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and acked_features of netdev could help to debug greatly.
This series export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up acked_features also exported, which is used to initialize or restore features negotiated between qemu and vhost slave when starting vhost_dev device.
Another thing the patchset did is adding a virtio-net features check test, which use the fresh new qmp interface "query-netdev" to check if features are negotiated correctly via vhost user protocol.
This patchset depends on the previous patchset which is in the process of code reviewing. So this post aims to request for comments as the subject say, any suggestions and comments are welcome and i would appreciate a lot.
Please review, thanks,
Hyman Huang (4):
net: Introduce qmp cmd "query-netdev"
hmp: Add "info netdev" cmd
hmp: Add netdev information into output of hmp cmd "info network"
vhost-user-test: Add negotiated features check
hmp-commands-info.hx | 14 +++++++ include/monitor/hmp.h | 1 + net/net.c | 90 +++++++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++ tests/qtest/vhost-user-test.c | 67 ++++++++++++++++++++++++++++++++ 5 files changed, 238 insertions(+)
Signature · 1 line
1.8.3.1
RFC PATCH 1/4 net: Introduce qmp cmd "query-netdev"
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and acked_features of netdev could also help to debug greatly.
So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up acked_features also exported, which is used to initialize or restore features negotiated between qemu and vhost slave when starting vhost_dev device.
--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)
net/net.c +44 -0
@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */
@@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; + +if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len; + +if (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { + info->has_acked_features = true; + info->acked_features =vhost_user_get_acked_features (nc); + } + +return info; +} + +NetDevInfoList *qmp_query_netdev (Error **errp) +{ +NetClientState *nc; +NetDevInfo *info =NULL ; +NetDevInfoList *head =NULL , **tail = &head; + + QTAILQ_FOREACH(nc, &net_clients, next) { +if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { +continue ; + } + + info =query_netdev (nc); +if (info) { +QAPI_LIST_APPEND (tail, info); + } + } + +return head; +} +static void netfilter_print_info (Monitor *mon,NetFilterState *nf) {char *str;
qapi/net.json +66 -0
72 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
Quoted 50 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)net/net.c +5
-0@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */ @@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; +
net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 10 lines
net/net.c +10
-0+if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;
So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
Thanks
Quoted 112 lines
net/net.c +29
-0+ +if (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { + info->has_acked_features = true; + info->acked_features =vhost_user_get_acked_features (nc); + } + +return info; +} + +NetDevInfoList *qmp_query_netdev (Error **errp) +{ +NetClientState *nc; +NetDevInfo *info =NULL ; +NetDevInfoList *head =NULL , **tail = &head; + + QTAILQ_FOREACH(nc, &net_clients, next) { +if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { +continue ; + } + + info =query_netdev (nc); +if (info) { +QAPI_LIST_APPEND (tail, info); + } + } + +return head; +} +static void netfilter_print_info (Monitor *mon,NetFilterState *nf) {char *str;qapi/net.json +66
-1@@ -631,6 +631,72 @@ 'if': 'CONFIG_VMNET' } } } ## +# @NetDevInfo: +# +# NetDev information. This structure describes a NetDev information, including +# capabilities and negotiated features. +# +# @name: The NetDev name. +# +# @type: Type of NetDev. +# +# @ufo: True if NetDev has ufo capability. +# +# @vnet-hdr: True if NetDev has vnet_hdr. +# +# @vnet-hdr-len: True if given length can be assigned to NetDev. +# +# @acked-features: Negotiated features with vhost slave device if device support +# dataplane offload. +# +# Since: 7.1 +## +{'struct': 'NetDevInfo', + 'data': { + 'name': 'str', + 'type': 'NetClientDriver', + 'ufo':'bool', + 'vnet-hdr':'bool', + 'vnet-hdr-len':'bool', + '*acked-features': 'uint64' } } + +## +# @query-netdev: +# +# Get a list of NetDevInfo for all virtual netdev peer devices. +# +# Returns: a list of @NetDevInfo describing each virtual netdev peer device. +# +# Since: 7.1 +# +# Example: +# +# -> { "execute": "query-netdev" } +# <- { +# "return":[ +# { +# "name":"hostnet0", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# }, +# { +# "name":"hostnet1", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# } +# ] +# } +# +## +{ 'command': 'query-netdev', 'returns': ['NetDevInfo'] } + +## # @RxState: # # Packets receiving state --1.8.3.1
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
Quoted 65 lines · Jason Wang
Quoted 50 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)net/net.c +5
-0@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */ @@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; +net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 10 lines
net/net.c +10
-0+if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
Quoted 1 line
Thanks
We have info virtio already. Seems to fit there logically.
Quoted 112 lines
Quoted 112 lines
net/net.c +29
-0+ +if (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { + info->has_acked_features = true; + info->acked_features =vhost_user_get_acked_features (nc); + } + +return info; +} + +NetDevInfoList *qmp_query_netdev (Error **errp) +{ +NetClientState *nc; +NetDevInfo *info =NULL ; +NetDevInfoList *head =NULL , **tail = &head; + + QTAILQ_FOREACH(nc, &net_clients, next) { +if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { +continue ; + } + + info =query_netdev (nc); +if (info) { +QAPI_LIST_APPEND (tail, info); + } + } + +return head; +} +static void netfilter_print_info (Monitor *mon,NetFilterState *nf) {char *str;qapi/net.json +66
-1@@ -631,6 +631,72 @@ 'if': 'CONFIG_VMNET' } } } ## +# @NetDevInfo: +# +# NetDev information. This structure describes a NetDev information, including +# capabilities and negotiated features. +# +# @name: The NetDev name. +# +# @type: Type of NetDev. +# +# @ufo: True if NetDev has ufo capability. +# +# @vnet-hdr: True if NetDev has vnet_hdr. +# +# @vnet-hdr-len: True if given length can be assigned to NetDev. +# +# @acked-features: Negotiated features with vhost slave device if device support +# dataplane offload. +# +# Since: 7.1 +## +{'struct': 'NetDevInfo', + 'data': { + 'name': 'str', + 'type': 'NetClientDriver', + 'ufo':'bool', + 'vnet-hdr':'bool', + 'vnet-hdr-len':'bool', + '*acked-features': 'uint64' } } + +## +# @query-netdev: +# +# Get a list of NetDevInfo for all virtual netdev peer devices. +# +# Returns: a list of @NetDevInfo describing each virtual netdev peer device. +# +# Since: 7.1 +# +# Example: +# +# -> { "execute": "query-netdev" } +# <- { +# "return":[ +# { +# "name":"hostnet0", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# }, +# { +# "name":"hostnet1", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# } +# ] +# } +# +## +{ 'command': 'query-netdev', 'returns': ['NetDevInfo'] } + +## # @RxState: # # Packets receiving state --1.8.3.1
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
Quoted 66 lines · Michael S. Tsirkin
Quoted 65 lines · Jason Wang
Quoted 50 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)net/net.c +5
-0@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */ @@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; +net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 10 lines
net/net.c +10
-0+if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
Quoted 3 lines
Quoted 1 line
Thanks
We have info virtio already. Seems to fit there logically.
Ok, it seems that 'x-query-virtio-netdev' is a good option.
Quoted 115 lines
Quoted 114 lines
Quoted 114 lines
net/net.c +29
-0+ +if (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { + info->has_acked_features = true; + info->acked_features =vhost_user_get_acked_features (nc); + } + +return info; +} + +NetDevInfoList *qmp_query_netdev (Error **errp) +{ +NetClientState *nc; +NetDevInfo *info =NULL ; +NetDevInfoList *head =NULL , **tail = &head; + + QTAILQ_FOREACH(nc, &net_clients, next) { +if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { +continue ; + } + + info =query_netdev (nc); +if (info) { +QAPI_LIST_APPEND (tail, info); + } + } + +return head; +} +static void netfilter_print_info (Monitor *mon,NetFilterState *nf) {char *str;qapi/net.json +66
-1@@ -631,6 +631,72 @@ 'if': 'CONFIG_VMNET' } } } ## +# @NetDevInfo: +# +# NetDev information. This structure describes a NetDev information, including +# capabilities and negotiated features. +# +# @name: The NetDev name. +# +# @type: Type of NetDev. +# +# @ufo: True if NetDev has ufo capability. +# +# @vnet-hdr: True if NetDev has vnet_hdr. +# +# @vnet-hdr-len: True if given length can be assigned to NetDev. +# +# @acked-features: Negotiated features with vhost slave device if device support +# dataplane offload. +# +# Since: 7.1 +## +{'struct': 'NetDevInfo', + 'data': { + 'name': 'str', + 'type': 'NetClientDriver', + 'ufo':'bool', + 'vnet-hdr':'bool', + 'vnet-hdr-len':'bool', + '*acked-features': 'uint64' } } + +## +# @query-netdev: +# +# Get a list of NetDevInfo for all virtual netdev peer devices. +# +# Returns: a list of @NetDevInfo describing each virtual netdev peer device. +# +# Since: 7.1 +# +# Example: +# +# -> { "execute": "query-netdev" } +# <- { +# "return":[ +# { +# "name":"hostnet0", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# }, +# { +# "name":"hostnet1", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# } +# ] +# } +# +## +{ 'command': 'query-netdev', 'returns': ['NetDevInfo'] } + +## # @RxState: # # Packets receiving state --1.8.3.1
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
In reply to Jason WangQuoted 56 lines · Jason Wang
Quoted 55 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)net/net.c +10
-0@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */ @@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; + +if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info));
Quoted 8 lines
net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 5 lines
net/net.c +5
-0+ info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
And add a "x-" prefix (and a "-netdev" suffix) as long as we don't feel confident about this yet? "x-query-virtio-netdev" ?
Thomas
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
Quoted 67 lines · Thomas Huth
Quoted 57 lines · Jason Wang
Quoted 56 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>---
net/net.c | 44 +++++++++++++++++++++++++++++++++++++++qapi/net.json| 66
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 110 insertions(+)net/net.c +10
-0@@ -53,6 +53,7 @@ #include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */@@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ + NetDevInfo *info = NULL; + + if (!nc || !nc->is_netdev) { + return NULL; + } + + info = g_malloc0(sizeof(*info));Quoted 8 lines
net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 5 lines
net/net.c +5
-0+ info->name = g_strdup(nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
Quoted 1 line
And add a "x-" prefix (and a "-netdev" suffix) as long as we don't feel confident about this yet? "x-query-virtio-netdev" ?
Agree with that, thanks for the comment.
Yong.
Quoted 3 lines
Thomas
Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
In reply to Jason WangQuoted 56 lines · Jason Wang
Quoted 55 lines · On Tue, Nov 1, 2022 at 12:19 AM <[email protected]> wrote:
From: Hyman Huang(黄勇) <[email protected]>
For netdev device that can offload virtio-net dataplane to slave, such as vhost-net, vhost-user and vhost-vdpa, exporting it's capability information and acked features would be more friendly for developers. These infomation can be analyzed and compare to slave capability provided by, eg dpdk or other slaves directly, helping to draw conclusions about if vm network interface works normally, if it vm can be migrated to another feature-compatible destination or whatever else.
For developers who devote to offload virtio-net dataplane to DPU and make efforts to migrate vm lively from software-based source host to DPU-offload destination host smoothly, virtio-net feature compatibility is an serious issue, exporting the key capability and
acked_featuresof netdev could also help to debug greatly.So we export out the key capabilities of netdev, which may affect the final negotiated virtio-net features, meanwhile, backed-up
acked_featuresalso exported, which is used to initialize or restore features negotiated between qemu and vhost slave when startingvhost_devdevice.Signed-off-by Hyman Huang(黄勇) <[email protected]>--- net/net.c | 44 +++++++++++++++++++++++++++++++++++++++ qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)net/net.c +10
-0@@ -53,6 +53,7 @@#include "sysemu/runstate.h" #include "net/colo-compare.h" #include "net/filter.h" +#include "net/vhost-user.h" #include "qapi/string-output-visitor.h" /* Net bridge is currently not supported for W32. */ @@ -1224,6 +1225,49 @@ void qmp_netdev_del(const char *id, Error **errp) } } +static NetDevInfo *query_netdev (NetClientState *nc) +{ +NetDevInfo *info =NULL ; + +if (!nc || !nc->is_netdev) { +return NULL ; + } + + info =g_malloc0 (sizeof (*info));
Quoted 8 lines
net/net.c void qmp_netdev_del(const char *id, Error **errp) · line 1241
Quoted 5 lines
net/net.c +5
-0+ info->name =g_strdup (nc->name); + info->type = nc->info->type; + info->ufo = nc->info->has_ufo; + info->vnet_hdr = nc->info->has_vnet_hdr; + info->vnet_hdr_len = nc->info->has_vnet_hdr_len;So all the fields are virtio specific, I wonder if it's better to rename the command as query-vhost or query-virtio?
Indeed, i'm also a little struggling about the naming, i prefer
Thomas's suggestion: 'x-query-virtio-netdev' and 'info virtio-netdev',
since we may add or del some capabilities about the *netdev* , so adding a "x-" prefix seems to reasonable, as to '-netdev' suffix, it implies the *backend*.
Thanks,
Yong
Quoted 116 lines
Thanks
Quoted 112 lines
net/net.c +29
-0+ +if (nc->info->type ==NET_CLIENT_DRIVER_VHOST_USER ) { + info->has_acked_features = true; + info->acked_features =vhost_user_get_acked_features (nc); + } + +return info; +} + +NetDevInfoList *qmp_query_netdev (Error **errp) +{ +NetClientState *nc; +NetDevInfo *info =NULL ; +NetDevInfoList *head =NULL , **tail = &head; + + QTAILQ_FOREACH(nc, &net_clients, next) { +if (nc->info->type ==NET_CLIENT_DRIVER_NIC ) { +continue ; + } + + info =query_netdev (nc); +if (info) { +QAPI_LIST_APPEND (tail, info); + } + } + +return head; +} +static void netfilter_print_info (Monitor *mon,NetFilterState *nf) {char *str;qapi/net.json +66
-1@@ -631,6 +631,72 @@ 'if': 'CONFIG_VMNET' } } } ## +# @NetDevInfo: +# +# NetDev information. This structure describes a NetDev information, including +# capabilities and negotiated features. +# +# @name: The NetDev name. +# +# @type: Type of NetDev. +# +# @ufo: True if NetDev has ufo capability. +# +# @vnet-hdr: True if NetDev has vnet_hdr. +# +# @vnet-hdr-len: True if given length can be assigned to NetDev. +# +# @acked-features: Negotiated features with vhost slave device if device support +# dataplane offload. +# +# Since: 7.1 +## +{'struct': 'NetDevInfo', + 'data': { + 'name': 'str', + 'type': 'NetClientDriver', + 'ufo':'bool', + 'vnet-hdr':'bool', + 'vnet-hdr-len':'bool', + '*acked-features': 'uint64' } } + +## +# @query-netdev: +# +# Get a list of NetDevInfo for all virtual netdev peer devices. +# +# Returns: a list of @NetDevInfo describing each virtual netdev peer device. +# +# Since: 7.1 +# +# Example: +# +# -> { "execute": "query-netdev" } +# <- { +# "return":[ +# { +# "name":"hostnet0", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# }, +# { +# "name":"hostnet1", +# "type":"vhost-user", +# "ufo":true, +# "vnet-hdr":true, +# "vnet-hdr-len":true, +# "acked-features":"5111807907", +# } +# ] +# } +# +## +{ 'command': 'query-netdev', 'returns': ['NetDevInfo'] } + +## # @RxState: # # Packets receiving state --1.8.3.1
RFC PATCH 2/4 hmp: Add "info netdev" cmd
In reply to [email protected]From: Hyman Huang(黄勇) <[email protected]>
Introduce "info netdev" command so developers can play with it easier.
--- hmp-commands-info.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + net/net.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)
hmp-commands-info.hx +14 -0
@@ -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",
include/monitor/hmp.h +1 -0
@@ -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
net/net.c +31 -0
@@ -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;
Signature · 1 line
1.8.3.1
Re: [PATCH RFC 2/4] hmp: Add "info netdev" cmd
Quoted 23 lines · On 31/10/2022 17.19, [email protected] wrote:
From: Hyman Huang(黄勇) <[email protected]>
Introduce "info netdev" command so developers can play with it easier.
Signed-off-by Hyman Huang(黄勇) <[email protected]>--- hmp-commands-info.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + net/net.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+)hmp-commands-info.hx +3
-0@@ -880,6 +880,20 @@ SRST Display the vcpu dirty page limit information. ERST + { + .name = "netdev", + .args_type = "",
hmp-commands-info.hx SRST · line 895
Quoted 10 lines
hmp-commands-info.hx +10
-0+ .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
Hmm, so according to the information, this shows information about the virtio *frontend*, but netdev is about *backends* (like TAP, slirp, VDE, ...) ... so this is definitely also the wrong naming here. Maybe rather "info virtio-net" or "info vhost-net" or something like that?
Thomas
RFC PATCH 3/4 hmp: Add netdev information into output of hmp cmd "info network"
In reply to [email protected]From: Hyman Huang(黄勇) <[email protected]>
Add netdev information into output of hmp command hmp_info_network so developers can analyze interface capability more easily.
--- net/net.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/net.c +15 -0
@@ -1330,6 +1330,21 @@ void print_net_client(Monitor *mon, NetClientState *nc) nc->queue_index,NetClientDriver_str (nc->info->type), nc->info_str); +if (nc->info->type !=NET_CLIENT_DRIVER_NIC ) { +NetDevInfo *info =query_netdev (nc); +if (info) { +monitor_printf (mon,"netdev info: ufo=%s, vnet-hdr=%s, " +"vnet-hdr-len=%s" , info->ufo ?"on" :"off" , + info->vnet_hdr ?"on" :"off" , + info->vnet_hdr_len ?"on" :"off" ); +if (info->has_acked_features) { +monitor_printf (mon,", acked-features=0x%" PRIx64, + info->acked_features); + } +monitor_printf (mon,"\n" ); +g_free (info); + } + }if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }
Signature · 1 line
1.8.3.1
RFC PATCH 4/4 vhost-user-test: Add negotiated features check
In reply to [email protected]From: Hyman Huang(黄勇) <[email protected]>
For vhost-user network device, Qemu backup the final features as acked_features internally after guest acknowledging features during virtio-net driver initialization, so the acked_features could be used as input of VHOST_USER_SET_FEATURES command when slave device restore from an unexpected failure.
Negotiated features check just assert if the acked_features in Qemu is exactly the same as features in vhost slave device, which checks if features are negotiated correctly via vhost user protocol.
--- tests/qtest/vhost-user-test.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
tests/qtest/vhost-user-test.c +67 -0
@@ -29,6 +29,9 @@#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" +#include "migration-helpers.h" +#include "qapi/qmp/qlist.h" +#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h"
@@ -167,6 +170,7 @@ typedef struct TestServer {int test_flags;int queues;struct vhost_user_ops *vu_ops; +uint64_t features; } TestServer;struct vhost_user_ops {
@@ -796,6 +800,64 @@ static void test_read_guest_mem(void *obj, void *arg, QGuestAllocator *alloc)read_guest_mem_server (global_qtest, server); } +static QDict *query_netdev (QTestState *who) +{ +QDict *rsp; + + rsp =qtest_qmp (who,"{ 'execute': 'query-netdev' }" ); +g_assert (!qdict_haskey (rsp,"error" )); +g_assert (qdict_haskey (rsp,"return" )); + +return rsp; +} + +static uint64_t get_acked_features (QTestState *who) +{ +QDict *rsp_return; +QList *info_list; +const QListEntry *entry; +QDict *info; +uint64_t acked_features; + + rsp_return =query_netdev (who); +g_assert (rsp_return); + + info_list =qdict_get_qlist (rsp_return,"return" ); +g_assert (info_list && !qlist_empty (info_list)); + + entry =qlist_first (info_list); +g_assert (entry); + + info =qobject_to (QDict,qlist_entry_obj (entry)); +g_assert (info); + + acked_features =qdict_get_try_int (info,"acked-features" ,0 ); + +qobject_unref (rsp_return); +return acked_features; +} + +static void read_acked_features (QTestState *qts,TestServer *s) +{ +uint64_t acked_features; + + acked_features =get_acked_features (qts); + g_assert_cmpint(acked_features, ==, s->features); +} + +static void test_read_acked_features (void *obj, +void *arg, +QGuestAllocator *alloc) +{ +TestServer *server = arg; + +if (!wait_for_fds (server)) { +return ; + } + +read_acked_features (global_qtest, server); +} +static void test_migrate (void *obj,void *arg,QGuestAllocator *alloc) {TestServer *s = arg;
@@ -1037,6 +1099,7 @@ static void vu_net_set_features(TestServer *s, CharBackend *chr,qemu_chr_fe_disconnect (chr); s->test_flags =TEST_FLAGS_BAD ; } + s->features = msg->payload.u64; } static void vu_net_get_protocol_features(TestServer *s, CharBackend *chr,
@@ -1078,6 +1141,10 @@ static void register_vhost_user_test(void)"virtio-net" , test_read_guest_mem, &opts); +qos_add_test ("vhost-user/read_acked_features" , +"virtio-net" , + test_read_acked_features, &opts); +if (qemu_memfd_check (MFD_ALLOW_SEALING )) { opts.before = vhost_user_test_setup_memfd; qos_add_test("vhost-user/read-guest-mem/memfd",
Signature · 1 line
1.8.3.1