qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: huangy81@chinatelecom.cn, qemu-devel <qemu-devel@nongnu.org>,
	Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Raphael Norwitz <raphael.norwitz@nutanix.com>
Subject: Re: [PATCH RFC 1/4] net: Introduce qmp cmd "query-netdev"
Date: Wed, 2 Nov 2022 02:41:51 -0400	[thread overview]
Message-ID: <20221102024054-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEvvoVwtr8aSqTpAVxYN7q7mxMmLbusfgKDf3zwfmk2itg@mail.gmail.com>

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
> >



  reply	other threads:[~2022-11-02  6:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-11-02  5:42   ` Jason Wang
2022-11-02  6:41     ` Michael S. Tsirkin [this message]
2022-11-02 15:36       ` Hyman
2022-11-02  7:10     ` Thomas Huth
2022-11-02 15:37       ` Hyman
2022-11-02 15:31     ` Hyman
2022-10-31 16:19 ` [PATCH RFC 2/4] hmp: Add "info netdev" cmd 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102024054-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=huangy81@chinatelecom.cn \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=sgarzare@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).