diff mbox

vfio/common: init giommu_list and hostwin_list of vfio container

Message ID 1511337482-15505-1-git-send-email-yi.l.liu@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liu, Yi L Nov. 22, 2017, 7:58 a.m. UTC
The init of giommu_list and hostwin_list is missed during container
initialization.

Signed-off-by: Liu, Yi L <yi.l.liu@linux.intel.com>
---
 hw/vfio/common.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Williamson Nov. 29, 2017, 3:41 p.m. UTC | #1
On Wed, 22 Nov 2017 15:58:02 +0800
"Liu, Yi L" <yi.l.liu@linux.intel.com> wrote:

> The init of giommu_list and hostwin_list is missed during container
> initialization.
> 
> Signed-off-by: Liu, Yi L <yi.l.liu@linux.intel.com>
> ---
>  hw/vfio/common.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7b2924c..14c5940 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -990,6 +990,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
>      container = g_malloc0(sizeof(*container));
>      container->space = space;
>      container->fd = fd;
> +    QLIST_INIT(&container->giommu_list);
> +    QLIST_INIT(&container->hostwin_list);

container is g_malloc0'd above and QLIST_INIT does:

#define QLIST_INIT(head) do {                                           \
        (head)->lh_first = NULL;                                        \
} while (/*CONSTCOND*/0)

So the only net change is the explicit initialization, which is a fair
fix, but given the current QLIST implementation is not actually a
bug.  Let's save it for after QEMU-2.11.  Thanks,

Alex

>      if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
>          ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
>          bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);
Liu, Yi L Nov. 30, 2017, 4:45 a.m. UTC | #2
On Wed, Nov 29, 2017 at 08:41:04AM -0700, Alex Williamson wrote:
> On Wed, 22 Nov 2017 15:58:02 +0800
> "Liu, Yi L" <yi.l.liu@linux.intel.com> wrote:
> 
> > The init of giommu_list and hostwin_list is missed during container
> > initialization.
> > 
> > Signed-off-by: Liu, Yi L <yi.l.liu@linux.intel.com>
> > ---
> >  hw/vfio/common.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index 7b2924c..14c5940 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -990,6 +990,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
> >      container = g_malloc0(sizeof(*container));
> >      container->space = space;
> >      container->fd = fd;
> > +    QLIST_INIT(&container->giommu_list);
> > +    QLIST_INIT(&container->hostwin_list);
> 
> container is g_malloc0'd above and QLIST_INIT does:
> 
> #define QLIST_INIT(head) do {                                           \
>         (head)->lh_first = NULL;                                        \
> } while (/*CONSTCOND*/0)
> 
> So the only net change is the explicit initialization, which is a fair
> fix, but given the current QLIST implementation is not actually a

Agree.

> bug.  Let's save it for after QEMU-2.11.  Thanks,

Thx, Alex. It's a nice plan.

Regards,
Yi L 
> Alex
> 
> >      if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
> >          ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
> >          bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);
> 
>
diff mbox

Patch

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7b2924c..14c5940 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -990,6 +990,8 @@  static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
     container = g_malloc0(sizeof(*container));
     container->space = space;
     container->fd = fd;
+    QLIST_INIT(&container->giommu_list);
+    QLIST_INIT(&container->hostwin_list);
     if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
         ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
         bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);