Hi Xueming, On Wed, Nov 24, 2021 at 06:17:40PM +0800, Xueming Li wrote: > Device iterator RTE_DEV_FOREACH() failed to return devices from > classifier like "class=vdpa", because matching name from empty kvargs > returns no result. If device name not specified in kvargs, the function > should iterate all devices. > > This patch allows empty devargs or devargs without name specified. > > Fixes: 6aebb942907d ("kvargs: add function to get from key and value") > Cc: olivier.m...@6wind.com > > Signed-off-by: Xueming Li <xuemi...@nvidia.com>
I just sent a v3 with the unit test. In case there is an issue with it, your v2 looks good to me: Acked-by: Olivier Matz <olivier.m...@6wind.com> As a side note, I was wondering if we should keep rte_kvargs_get_with_value() in kvargs api, since there is no more user. I think there it can still be useful, let's keep it for now. Thanks! Olivier > --- > 21.11 specific bug, no copy to stable.org > --- > drivers/bus/auxiliary/auxiliary_params.c | 14 +++++++++----- > drivers/bus/vdev/vdev_params.c | 14 +++++++++----- > 2 files changed, 18 insertions(+), 10 deletions(-) > > diff --git a/drivers/bus/auxiliary/auxiliary_params.c > b/drivers/bus/auxiliary/auxiliary_params.c > index a9c7853ed1d..9cbc1f7c777 100644 > --- a/drivers/bus/auxiliary/auxiliary_params.c > +++ b/drivers/bus/auxiliary/auxiliary_params.c > @@ -26,11 +26,15 @@ auxiliary_dev_match(const struct rte_device *dev, > { > const struct rte_kvargs *kvlist = _kvlist; > const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME]; > - > - if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) > - return -1; > - > - return 0; > + const char *name; > + > + if (kvlist == NULL) > + return 0; > + name = rte_kvargs_get(kvlist, key); > + if (name == NULL) > + /* Iterate all devices if name not specified. */ > + return 0; > + return strcmp(name, dev->name); > } > > void * > diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c > index 37d95395e7a..b4baecb7c0d 100644 > --- a/drivers/bus/vdev/vdev_params.c > +++ b/drivers/bus/vdev/vdev_params.c > @@ -28,11 +28,15 @@ vdev_dev_match(const struct rte_device *dev, > { > const struct rte_kvargs *kvlist = _kvlist; > const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME]; > - > - if (rte_kvargs_get_with_value(kvlist, key, dev->name) == NULL) > - return -1; > - > - return 0; > + const char *name; > + > + if (kvlist == NULL) > + return 0; > + name = rte_kvargs_get(kvlist, key); > + if (name == NULL) > + /* Iterate all devices if name not specified. */ > + return 0; > + return strcmp(name, dev->name); > } > > void * > -- > 2.34.0 >