[libvirt PATCH 1/6] nodedev: factor out nodeDeviceHasCapability()

Erik Skultety eskultet at redhat.com
Tue May 19 06:38:56 UTC 2020


On Mon, May 11, 2020 at 03:28:03PM +0200, Michal Privoznik wrote:
> On 4/30/20 11:42 PM, Jonathon Jongsma wrote:
> > Currently nodeDeviceCreateXML() and nodeDeviceDestroy() only support
> > NPIV HBAs, but we want to be able to create mdev devices as well. This
> > is a first step to enabling that support.
> > 
> > Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> > ---
> >   src/node_device/node_device_driver.c | 90 ++++++++++++++++++----------
> >   1 file changed, 57 insertions(+), 33 deletions(-)
> > 
> > diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> > index ee175e1095..6a96a77d92 100644
> > --- a/src/node_device/node_device_driver.c
> > +++ b/src/node_device/node_device_driver.c
> > @@ -487,6 +487,20 @@ nodeDeviceFindNewDevice(virConnectPtr conn,
> >       return device;
> >   }
> > +static bool
> > +nodeDeviceHasCapability(virNodeDeviceDefPtr def, virNodeDevCapType type)
> > +{
> > +    virNodeDevCapsDefPtr cap = NULL;
> > +
> > +    cap = def->caps;
> 
> This variable can be initialized to def->caps directly. No need to go
> through NULL, IMO.
> 
> > +    while (cap != NULL) {
> > +        if (cap->data.type == type)
> > +            return true;
> > +        cap = cap->next;
> > +    }
> > +
> > +    return false;
> > +}
> 
> 
> Also, here and for the rest of the patchset - the file uses two spaces
> between functions. Please keep that.
> 
> Michal
> 

With the suggested changes:
Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list