HI David,

Thanks for your reply.
I will send out a version to address that.

> -----Original Message-----
> From: David Marchand <david.march...@redhat.com>
> Sent: Monday, April 25, 2022 9:05 PM
> To: Pei, Andy <andy....@intel.com>
> Cc: dev <dev@dpdk.org>; Xia, Chenbo <chenbo....@intel.com>; Maxime
> Coquelin <maxime.coque...@redhat.com>; Cao, Gang
> <gang....@intel.com>; Liu, Changpeng <changpeng....@intel.com>
> Subject: Re: [PATCH v6 03/16] vhost: add vhost msg support
> 
> On Thu, Apr 21, 2022 at 11:20 AM Andy Pei <andy....@intel.com> wrote:
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index
> > 1d39067..3780804 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -80,6 +80,8 @@
> >         [VHOST_USER_NET_SET_MTU]  = "VHOST_USER_NET_SET_MTU",
> >         [VHOST_USER_SET_SLAVE_REQ_FD]  =
> "VHOST_USER_SET_SLAVE_REQ_FD",
> >         [VHOST_USER_IOTLB_MSG]  = "VHOST_USER_IOTLB_MSG",
> > +       [VHOST_USER_GET_CONFIG]  = "VHOST_USER_GET_CONFIG",
> > +       [VHOST_USER_SET_CONFIG]  = "VHOST_USER_SET_CONFIG",
> >         [VHOST_USER_CRYPTO_CREATE_SESS] =
> "VHOST_USER_CRYPTO_CREATE_SESS",
> >         [VHOST_USER_CRYPTO_CLOSE_SESS] =
> "VHOST_USER_CRYPTO_CLOSE_SESS",
> >         [VHOST_USER_POSTCOPY_ADVISE]  =
> "VHOST_USER_POSTCOPY_ADVISE",
> > @@ -2542,6 +2544,71 @@ static int is_vring_iotlb(struct virtio_net
> > *dev,  }
> >
> >  static int
> > +vhost_user_get_config(struct virtio_net **pdev,
> > +                       struct vhu_msg_context *ctx,
> > +                       int main_fd __rte_unused) {
> > +       struct virtio_net *dev = *pdev;
> > +       struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev;
> > +       int ret = 0;
> 
> You must check if there is any fd attached to this message.
> 
> 
> > +
> > +       if (vdpa_dev->ops->get_config) {
> > +               ret = vdpa_dev->ops->get_config(dev->vid,
> > +                                          ctx->msg.payload.cfg.region,
> > +                                          ctx->msg.payload.cfg.size);
> > +               if (ret != 0) {
> > +                       ctx->msg.size = 0;
> > +                       VHOST_LOG_CONFIG(ERR,
> > +                                        "(%s) get_config() return 
> > error!\n",
> > +                                        dev->ifname);
> > +               }
> > +       } else {
> > +               VHOST_LOG_CONFIG(ERR, "(%s) get_config() not supportted!\n",
> > +                                dev->ifname);
> > +       }
> > +
> > +       return RTE_VHOST_MSG_RESULT_REPLY; }
> > +
> > +static int
> > +vhost_user_set_config(struct virtio_net **pdev,
> > +                       struct vhu_msg_context *ctx,
> > +                       int main_fd __rte_unused) {
> > +       struct virtio_net *dev = *pdev;
> > +       struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev;
> > +       int ret = 0;
> 
> Idem.
> 
> 
> > +
> > +       if (ctx->msg.size != sizeof(struct vhost_user_config)) {
> > +               VHOST_LOG_CONFIG(ERR,
> > +                       "(%s) invalid set config msg size: %"PRId32" != 
> > %d\n",
> > +                       dev->ifname, ctx->msg.size,
> > +                       (int)sizeof(struct vhost_user_config));
> > +               goto OUT;
> > +       }
> 
> 
> For info, I posted a series to make this kind of check more systematic.
> See:
> https://patchwork.dpdk.org/project/dpdk/patch/20220425125431.26464-2-
> david.march...@redhat.com/
> 
> 
> 
> --
> David Marchand

Reply via email to