* [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-10-31 16:18 [PATCH RFC 0/4] Export netdev capabilities and information huangy81
@ 2022-10-31 16:18 ` huangy81
2022-11-02 5:42 ` Jason Wang
2022-10-31 16:19 ` [PATCH RFC 2/4] hmp: Add "info netdev" cmd huangy81
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: huangy81 @ 2022-10-31 16:18 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Jason Wang, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz,
Hyman Huang(黄勇)
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
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.
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+)
diff --git a/net/net.c b/net/net.c
index 2db160e..5d11674 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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;
diff --git a/qapi/net.json b/qapi/net.json
index dd088c0..76a6513 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-10-31 16:18 ` [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev" huangy81
@ 2022-11-02 5:42 ` Jason Wang
2022-11-02 6:41 ` Michael S. Tsirkin
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Jason Wang @ 2022-11-02 5:42 UTC (permalink / raw)
To: huangy81
Cc: qemu-devel, Michael S . Tsirkin, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz
On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
>
> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>
> 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.
>
> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> ---
> net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
> qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 110 insertions(+)
>
> diff --git a/net/net.c b/net/net.c
> index 2db160e..5d11674 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -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;
So all the fields are virtio specific, I wonder if it's better to
rename the command as query-vhost or query-virtio?
Thanks
> +
> + 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;
> diff --git a/qapi/net.json b/qapi/net.json
> index dd088c0..76a6513 100644
> --- a/qapi/net.json
> +++ b/qapi/net.json
> @@ -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
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-11-02 5:42 ` Jason Wang
@ 2022-11-02 6:41 ` Michael S. Tsirkin
2022-11-02 15:36 ` Hyman
2022-11-02 7:10 ` Thomas Huth
2022-11-02 15:31 ` Hyman
2 siblings, 1 reply; 12+ messages in thread
From: Michael S. Tsirkin @ 2022-11-02 6:41 UTC (permalink / raw)
To: Jason Wang
Cc: huangy81, qemu-devel, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz
On Wed, Nov 02, 2022 at 01:42:39PM +0800, Jason Wang wrote:
> On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
> >
> > From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> >
> > 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.
> >
> > Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
> > ---
> > net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
> > qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 110 insertions(+)
> >
> > diff --git a/net/net.c b/net/net.c
> > index 2db160e..5d11674 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -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;
>
> So all the fields are virtio specific, I wonder if it's better to
> rename the command as query-vhost or query-virtio?
>
> Thanks
We have info virtio already. Seems to fit there logically.
> > +
> > + 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;
> > diff --git a/qapi/net.json b/qapi/net.json
> > index dd088c0..76a6513 100644
> > --- a/qapi/net.json
> > +++ b/qapi/net.json
> > @@ -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
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-11-02 6:41 ` Michael S. Tsirkin
@ 2022-11-02 15:36 ` Hyman
0 siblings, 0 replies; 12+ messages in thread
From: Hyman @ 2022-11-02 15:36 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang
Cc: qemu-devel, Eric Blake, Markus Armbruster, Dr. David Alan Gilbert,
Thomas Huth, Laurent Vivier, Paolo Bonzini, Stefano Garzarella,
Raphael Norwitz
在 2022/11/2 14:41, Michael S. Tsirkin 写道:
> On Wed, Nov 02, 2022 at 01:42:39PM +0800, Jason Wang wrote:
>> On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
>>>
>>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>>
>>> 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.
>>>
>>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>> ---
>>> net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
>>> qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 110 insertions(+)
>>>
>>> diff --git a/net/net.c b/net/net.c
>>> index 2db160e..5d11674 100644
>>> --- a/net/net.c
>>> +++ b/net/net.c
>>> @@ -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;
>>
>> So all the fields are virtio specific, I wonder if it's better to
>> rename the command as query-vhost or query-virtio?
>>
>> Thanks
>
> We have info virtio already. Seems to fit there logically.
Ok, it seems that 'x-query-virtio-netdev' is a good option.
>
>
>>> +
>>> + 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;
>>> diff --git a/qapi/net.json b/qapi/net.json
>>> index dd088c0..76a6513 100644
>>> --- a/qapi/net.json
>>> +++ b/qapi/net.json
>>> @@ -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
>>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-11-02 5:42 ` Jason Wang
2022-11-02 6:41 ` Michael S. Tsirkin
@ 2022-11-02 7:10 ` Thomas Huth
2022-11-02 15:37 ` Hyman
2022-11-02 15:31 ` Hyman
2 siblings, 1 reply; 12+ messages in thread
From: Thomas Huth @ 2022-11-02 7:10 UTC (permalink / raw)
To: Jason Wang, huangy81
Cc: qemu-devel, Michael S . Tsirkin, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Laurent Vivier, Paolo Bonzini,
Stefano Garzarella, Raphael Norwitz
On 02/11/2022 06.42, Jason Wang wrote:
> On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
>>
>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>
>> 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.
>>
>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>> ---
>> net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
>> qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 110 insertions(+)
>>
>> diff --git a/net/net.c b/net/net.c
>> index 2db160e..5d11674 100644
>> --- a/net/net.c
>> +++ b/net/net.c
>> @@ -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;
>
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-11-02 7:10 ` Thomas Huth
@ 2022-11-02 15:37 ` Hyman
0 siblings, 0 replies; 12+ messages in thread
From: Hyman @ 2022-11-02 15:37 UTC (permalink / raw)
To: Thomas Huth, Jason Wang
Cc: qemu-devel, Michael S . Tsirkin, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Laurent Vivier, Paolo Bonzini,
Stefano Garzarella, Raphael Norwitz
在 2022/11/2 15:10, Thomas Huth 写道:
> On 02/11/2022 06.42, Jason Wang wrote:
>> On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
>>>
>>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>>
>>> 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.
>>>
>>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>> ---
>>> net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
>>> qapi/net.json | 66
>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 110 insertions(+)
>>>
>>> diff --git a/net/net.c b/net/net.c
>>> index 2db160e..5d11674 100644
>>> --- a/net/net.c
>>> +++ b/net/net.c
>>> @@ -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;
>>
>> 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" ?
Agree with that, thanks for the comment.
Yong.
>
> Thomas
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
2022-11-02 5:42 ` Jason Wang
2022-11-02 6:41 ` Michael S. Tsirkin
2022-11-02 7:10 ` Thomas Huth
@ 2022-11-02 15:31 ` Hyman
2 siblings, 0 replies; 12+ messages in thread
From: Hyman @ 2022-11-02 15:31 UTC (permalink / raw)
To: Jason Wang
Cc: qemu-devel, Michael S . Tsirkin, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz
在 2022/11/2 13:42, Jason Wang 写道:
> On Tue, Nov 1, 2022 at 12:19 AM <huangy81@chinatelecom.cn> wrote:
>>
>> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>>
>> 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.
>>
>> Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>> ---
>> net/net.c | 44 +++++++++++++++++++++++++++++++++++++++
>> qapi/net.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 110 insertions(+)
>>
>> diff --git a/net/net.c b/net/net.c
>> index 2db160e..5d11674 100644
>> --- a/net/net.c
>> +++ b/net/net.c
>> @@ -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;
>
> 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
>
> Thanks
>
>> +
>> + 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;
>> diff --git a/qapi/net.json b/qapi/net.json
>> index dd088c0..76a6513 100644
>> --- a/qapi/net.json
>> +++ b/qapi/net.json
>> @@ -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
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH RFC 2/4] hmp: Add "info netdev" cmd
2022-10-31 16:18 [PATCH RFC 0/4] Export netdev capabilities and information huangy81
2022-10-31 16:18 ` [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev" huangy81
@ 2022-10-31 16:19 ` huangy81
2022-11-02 7:13 ` Thomas Huth
2022-10-31 16:19 ` [PATCH RFC 3/4] hmp: Add netdev information into output of hmp cmd "info network" huangy81
2022-10-31 16:19 ` [PATCH RFC 4/4] vhost-user-test: Add negotiated features check huangy81
3 siblings, 1 reply; 12+ messages in thread
From: huangy81 @ 2022-10-31 16:19 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Jason Wang, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz,
Hyman Huang(黄勇)
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Introduce "info netdev" command so developers can play with
it easier.
Signed-off-by: Hyman Huang(黄勇) <huangy81@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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH RFC 2/4] hmp: Add "info netdev" cmd
2022-10-31 16:19 ` [PATCH RFC 2/4] hmp: Add "info netdev" cmd huangy81
@ 2022-11-02 7:13 ` Thomas Huth
0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2022-11-02 7:13 UTC (permalink / raw)
To: huangy81, qemu-devel
Cc: Michael S . Tsirkin, Jason Wang, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Laurent Vivier, Paolo Bonzini,
Stefano Garzarella, Raphael Norwitz
On 31/10/2022 17.19, huangy81@chinatelecom.cn wrote:
> From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
>
> Introduce "info netdev" command so developers can play with
> it easier.
>
> Signed-off-by: Hyman Huang(黄勇) <huangy81@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
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH RFC 3/4] hmp: Add netdev information into output of hmp cmd "info network"
2022-10-31 16:18 [PATCH RFC 0/4] Export netdev capabilities and information huangy81
2022-10-31 16:18 ` [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev" huangy81
2022-10-31 16:19 ` [PATCH RFC 2/4] hmp: Add "info netdev" cmd huangy81
@ 2022-10-31 16:19 ` huangy81
2022-10-31 16:19 ` [PATCH RFC 4/4] vhost-user-test: Add negotiated features check huangy81
3 siblings, 0 replies; 12+ messages in thread
From: huangy81 @ 2022-10-31 16:19 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Jason Wang, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz,
Hyman Huang(黄勇)
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Add netdev information into output of hmp command hmp_info_network
so developers can analyze interface capability more easily.
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
net/net.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/net/net.c b/net/net.c
index c27ebfa..9325628 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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");
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH RFC 4/4] vhost-user-test: Add negotiated features check
2022-10-31 16:18 [PATCH RFC 0/4] Export netdev capabilities and information huangy81
` (2 preceding siblings ...)
2022-10-31 16:19 ` [PATCH RFC 3/4] hmp: Add netdev information into output of hmp cmd "info network" huangy81
@ 2022-10-31 16:19 ` huangy81
3 siblings, 0 replies; 12+ messages in thread
From: huangy81 @ 2022-10-31 16:19 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Jason Wang, Eric Blake, Markus Armbruster,
Dr. David Alan Gilbert, Thomas Huth, Laurent Vivier,
Paolo Bonzini, Stefano Garzarella, Raphael Norwitz,
Hyman Huang(黄勇)
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
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.
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
tests/qtest/vhost-user-test.c | 67 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index bf9f7c4..f8bf2fa 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -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",
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread