bus/vdev: add warning for duplicated vdev name
diff mbox series

Message ID 20181129071608.20820-1-yahui.cao@intel.com
State New
Delegated to: Thomas Monjalon
Headers show
Series
  • bus/vdev: add warning for duplicated vdev name
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Yahui Cao Nov. 29, 2018, 7:16 a.m. UTC
If duplicated vdev name is detected, print out a warning message.

Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
 drivers/bus/vdev/vdev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Thomas Monjalon Dec. 19, 2018, 2:26 a.m. UTC | #1
29/11/2018 08:16, Yahui Cao:
> If duplicated vdev name is detected, print out a warning message.
> 
> Signed-off-by: Yahui Cao <yahui.cao@intel.com>
> ---
>  drivers/bus/vdev/vdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index 9c66bdc78..ff2db7d3f 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -462,6 +462,8 @@ vdev_scan(void)
>  		if (find_vdev(devargs->name)) {
>  			rte_spinlock_recursive_unlock(&vdev_device_list_lock);
>  			free(dev);
> +			VDEV_LOG(WARNING, "duplicated vdev name %s detected!",
> +				devargs->name);
>  			continue;
>  		}

I'm surprised there is nothing to prevent from creating 2 vdevs
with the same name. It should be considered as an error
and reject the vdev creation.
Yahui Cao Dec. 21, 2018, 6:57 a.m. UTC | #2
On Wed, Dec 19, 2018 at 03:26:36AM +0100, Thomas Monjalon wrote:
> 29/11/2018 08:16, Yahui Cao:
> > If duplicated vdev name is detected, print out a warning message.
> > 
> > Signed-off-by: Yahui Cao <yahui.cao@intel.com>
> > ---
> >  drivers/bus/vdev/vdev.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> > index 9c66bdc78..ff2db7d3f 100644
> > --- a/drivers/bus/vdev/vdev.c
> > +++ b/drivers/bus/vdev/vdev.c
> > @@ -462,6 +462,8 @@ vdev_scan(void)
> >  		if (find_vdev(devargs->name)) {
> >  			rte_spinlock_recursive_unlock(&vdev_device_list_lock);
> >  			free(dev);
> > +			VDEV_LOG(WARNING, "duplicated vdev name %s detected!",
> > +				devargs->name);
> >  			continue;
> >  		}
> 
> I'm surprised there is nothing to prevent from creating 2 vdevs
> with the same name. It should be considered as an error
> and reject the vdev creation.
> 
> 
Actually it does skip the creation of vdev with the same name. Is it
enough to return error from vdev_scan(), or even return error from
rte_bus_scan()? Please give some advice.

Patch
diff mbox series

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 9c66bdc78..ff2db7d3f 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -462,6 +462,8 @@  vdev_scan(void)
 		if (find_vdev(devargs->name)) {
 			rte_spinlock_recursive_unlock(&vdev_device_list_lock);
 			free(dev);
+			VDEV_LOG(WARNING, "duplicated vdev name %s detected!",
+				devargs->name);
 			continue;
 		}