diff mbox series

[v1,05/10] vhost-backend: export the vhost backend helper

Message ID 20200622153756.19189-6-lulu@redhat.com (mailing list archive)
State New, archived
Headers show
Series vDPA support in qemu | expand

Commit Message

Cindy Lu June 22, 2020, 3:37 p.m. UTC
export the helper then we can reuse them in other backend

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 hw/virtio/vhost-backend.c         | 18 +++++++++---------
 include/hw/virtio/vhost-backend.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 9 deletions(-)

Comments

Laurent Vivier June 25, 2020, 3:07 p.m. UTC | #1
On 22/06/2020 17:37, Cindy Lu wrote:
> export the helper then we can reuse them in other backend
> 
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
>  hw/virtio/vhost-backend.c         | 18 +++++++++---------
>  include/hw/virtio/vhost-backend.h | 28 ++++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+), 9 deletions(-)
> 

This looks weird to export all these functions whereas they are all
already exported by the vhost_ops structure.

So if vhost-vdpa is not a subset of vhost-kernel and if these functions
will diverge from vhost-backend.c definition in the future, perhaps it
is wise to already copy their definitions right now in vhost-vdpa.c
rather than exporting them now and to have to copy them in the future in
vhost-vdpa.c to modify them.

It will also simplify the definition of vhost_kernel_call().

Thanks,
Laurent

> diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> index 48905383f8..660e9e8588 100644
> --- a/hw/virtio/vhost-backend.c
> +++ b/hw/virtio/vhost-backend.c
> @@ -89,7 +89,7 @@ static int vhost_kernel_scsi_get_abi_version(struct vhost_dev *dev, int *version
>      return vhost_kernel_call(dev, VHOST_SCSI_GET_ABI_VERSION, version);
>  }
>  
> -static int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
> +int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
>                                       struct vhost_log *log)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base);
> @@ -101,7 +101,7 @@ static int vhost_kernel_set_mem_table(struct vhost_dev *dev,
>      return vhost_kernel_call(dev, VHOST_SET_MEM_TABLE, mem);
>  }
>  
> -static int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
> +int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
>                                         struct vhost_vring_addr *addr)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_VRING_ADDR, addr);
> @@ -113,31 +113,31 @@ static int vhost_kernel_set_vring_endian(struct vhost_dev *dev,
>      return vhost_kernel_call(dev, VHOST_SET_VRING_ENDIAN, ring);
>  }
>  
> -static int vhost_kernel_set_vring_num(struct vhost_dev *dev,
> +int vhost_kernel_set_vring_num(struct vhost_dev *dev,
>                                        struct vhost_vring_state *ring)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_VRING_NUM, ring);
>  }
>  
> -static int vhost_kernel_set_vring_base(struct vhost_dev *dev,
> +int vhost_kernel_set_vring_base(struct vhost_dev *dev,
>                                         struct vhost_vring_state *ring)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_VRING_BASE, ring);
>  }
>  
> -static int vhost_kernel_get_vring_base(struct vhost_dev *dev,
> +int vhost_kernel_get_vring_base(struct vhost_dev *dev,
>                                         struct vhost_vring_state *ring)
>  {
>      return vhost_kernel_call(dev, VHOST_GET_VRING_BASE, ring);
>  }
>  
> -static int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
> +int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
>                                         struct vhost_vring_file *file)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_VRING_KICK, file);
>  }
>  
> -static int vhost_kernel_set_vring_call(struct vhost_dev *dev,
> +int vhost_kernel_set_vring_call(struct vhost_dev *dev,
>                                         struct vhost_vring_file *file)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_VRING_CALL, file);
> @@ -155,13 +155,13 @@ static int vhost_kernel_set_features(struct vhost_dev *dev,
>      return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features);
>  }
>  
> -static int vhost_kernel_get_features(struct vhost_dev *dev,
> +int vhost_kernel_get_features(struct vhost_dev *dev,
>                                       uint64_t *features)
>  {
>      return vhost_kernel_call(dev, VHOST_GET_FEATURES, features);
>  }
>  
> -static int vhost_kernel_set_owner(struct vhost_dev *dev)
> +int vhost_kernel_set_owner(struct vhost_dev *dev)
>  {
>      return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL);
>  }
> diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
> index 6f6670783f..300b59c172 100644
> --- a/include/hw/virtio/vhost-backend.h
> +++ b/include/hw/virtio/vhost-backend.h
> @@ -172,4 +172,32 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
>  
>  int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);
>  
> +
> +int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
> +                                     struct vhost_log *log);
> +
> +int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
> +                                       struct vhost_vring_addr *addr);
> +
> +int vhost_kernel_set_vring_num(struct vhost_dev *dev,
> +                                      struct vhost_vring_state *ring);
> +
> +int vhost_kernel_set_vring_base(struct vhost_dev *dev,
> +                                       struct vhost_vring_state *ring);
> +
> +int vhost_kernel_get_vring_base(struct vhost_dev *dev,
> +                                       struct vhost_vring_state *ring);
> +
> +int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
> +                                       struct vhost_vring_file *file);
> +
> +int vhost_kernel_set_vring_call(struct vhost_dev *dev,
> +                                       struct vhost_vring_file *file);
> +
> +int vhost_kernel_set_owner(struct vhost_dev *dev);
> +
> +int vhost_kernel_get_features(struct vhost_dev *dev,
> +                                     uint64_t *features);
> +
> +
>  #endif /* VHOST_BACKEND_H */
>
Cindy Lu June 30, 2020, 6:27 a.m. UTC | #2
On Thu, Jun 25, 2020 at 11:07 PM Laurent Vivier <lvivier@redhat.com> wrote:
>
> On 22/06/2020 17:37, Cindy Lu wrote:
> > export the helper then we can reuse them in other backend
> >
> > Signed-off-by: Cindy Lu <lulu@redhat.com>
> > ---
> >  hw/virtio/vhost-backend.c         | 18 +++++++++---------
> >  include/hw/virtio/vhost-backend.h | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 37 insertions(+), 9 deletions(-)
> >
>
> This looks weird to export all these functions whereas they are all
> already exported by the vhost_ops structure.
>
> So if vhost-vdpa is not a subset of vhost-kernel and if these functions
> will diverge from vhost-backend.c definition in the future, perhaps it
> is wise to already copy their definitions right now in vhost-vdpa.c
> rather than exporting them now and to have to copy them in the future in
> vhost-vdpa.c to modify them.
>
> It will also simplify the definition of vhost_kernel_call().
>
> Thanks,
> Laurent
>
Thanks Laurent, will fix this
> > diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> > index 48905383f8..660e9e8588 100644
> > --- a/hw/virtio/vhost-backend.c
> > +++ b/hw/virtio/vhost-backend.c
> > @@ -89,7 +89,7 @@ static int vhost_kernel_scsi_get_abi_version(struct vhost_dev *dev, int *version
> >      return vhost_kernel_call(dev, VHOST_SCSI_GET_ABI_VERSION, version);
> >  }
> >
> > -static int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
> > +int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
> >                                       struct vhost_log *log)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base);
> > @@ -101,7 +101,7 @@ static int vhost_kernel_set_mem_table(struct vhost_dev *dev,
> >      return vhost_kernel_call(dev, VHOST_SET_MEM_TABLE, mem);
> >  }
> >
> > -static int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
> > +int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
> >                                         struct vhost_vring_addr *addr)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_ADDR, addr);
> > @@ -113,31 +113,31 @@ static int vhost_kernel_set_vring_endian(struct vhost_dev *dev,
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_ENDIAN, ring);
> >  }
> >
> > -static int vhost_kernel_set_vring_num(struct vhost_dev *dev,
> > +int vhost_kernel_set_vring_num(struct vhost_dev *dev,
> >                                        struct vhost_vring_state *ring)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_NUM, ring);
> >  }
> >
> > -static int vhost_kernel_set_vring_base(struct vhost_dev *dev,
> > +int vhost_kernel_set_vring_base(struct vhost_dev *dev,
> >                                         struct vhost_vring_state *ring)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_BASE, ring);
> >  }
> >
> > -static int vhost_kernel_get_vring_base(struct vhost_dev *dev,
> > +int vhost_kernel_get_vring_base(struct vhost_dev *dev,
> >                                         struct vhost_vring_state *ring)
> >  {
> >      return vhost_kernel_call(dev, VHOST_GET_VRING_BASE, ring);
> >  }
> >
> > -static int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
> > +int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
> >                                         struct vhost_vring_file *file)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_KICK, file);
> >  }
> >
> > -static int vhost_kernel_set_vring_call(struct vhost_dev *dev,
> > +int vhost_kernel_set_vring_call(struct vhost_dev *dev,
> >                                         struct vhost_vring_file *file)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_VRING_CALL, file);
> > @@ -155,13 +155,13 @@ static int vhost_kernel_set_features(struct vhost_dev *dev,
> >      return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features);
> >  }
> >
> > -static int vhost_kernel_get_features(struct vhost_dev *dev,
> > +int vhost_kernel_get_features(struct vhost_dev *dev,
> >                                       uint64_t *features)
> >  {
> >      return vhost_kernel_call(dev, VHOST_GET_FEATURES, features);
> >  }
> >
> > -static int vhost_kernel_set_owner(struct vhost_dev *dev)
> > +int vhost_kernel_set_owner(struct vhost_dev *dev)
> >  {
> >      return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL);
> >  }
> > diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
> > index 6f6670783f..300b59c172 100644
> > --- a/include/hw/virtio/vhost-backend.h
> > +++ b/include/hw/virtio/vhost-backend.h
> > @@ -172,4 +172,32 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
> >
> >  int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);
> >
> > +
> > +int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
> > +                                     struct vhost_log *log);
> > +
> > +int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
> > +                                       struct vhost_vring_addr *addr);
> > +
> > +int vhost_kernel_set_vring_num(struct vhost_dev *dev,
> > +                                      struct vhost_vring_state *ring);
> > +
> > +int vhost_kernel_set_vring_base(struct vhost_dev *dev,
> > +                                       struct vhost_vring_state *ring);
> > +
> > +int vhost_kernel_get_vring_base(struct vhost_dev *dev,
> > +                                       struct vhost_vring_state *ring);
> > +
> > +int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
> > +                                       struct vhost_vring_file *file);
> > +
> > +int vhost_kernel_set_vring_call(struct vhost_dev *dev,
> > +                                       struct vhost_vring_file *file);
> > +
> > +int vhost_kernel_set_owner(struct vhost_dev *dev);
> > +
> > +int vhost_kernel_get_features(struct vhost_dev *dev,
> > +                                     uint64_t *features);
> > +
> > +
> >  #endif /* VHOST_BACKEND_H */
> >
>
diff mbox series

Patch

diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 48905383f8..660e9e8588 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -89,7 +89,7 @@  static int vhost_kernel_scsi_get_abi_version(struct vhost_dev *dev, int *version
     return vhost_kernel_call(dev, VHOST_SCSI_GET_ABI_VERSION, version);
 }
 
-static int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
+int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
                                      struct vhost_log *log)
 {
     return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base);
@@ -101,7 +101,7 @@  static int vhost_kernel_set_mem_table(struct vhost_dev *dev,
     return vhost_kernel_call(dev, VHOST_SET_MEM_TABLE, mem);
 }
 
-static int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
+int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
                                        struct vhost_vring_addr *addr)
 {
     return vhost_kernel_call(dev, VHOST_SET_VRING_ADDR, addr);
@@ -113,31 +113,31 @@  static int vhost_kernel_set_vring_endian(struct vhost_dev *dev,
     return vhost_kernel_call(dev, VHOST_SET_VRING_ENDIAN, ring);
 }
 
-static int vhost_kernel_set_vring_num(struct vhost_dev *dev,
+int vhost_kernel_set_vring_num(struct vhost_dev *dev,
                                       struct vhost_vring_state *ring)
 {
     return vhost_kernel_call(dev, VHOST_SET_VRING_NUM, ring);
 }
 
-static int vhost_kernel_set_vring_base(struct vhost_dev *dev,
+int vhost_kernel_set_vring_base(struct vhost_dev *dev,
                                        struct vhost_vring_state *ring)
 {
     return vhost_kernel_call(dev, VHOST_SET_VRING_BASE, ring);
 }
 
-static int vhost_kernel_get_vring_base(struct vhost_dev *dev,
+int vhost_kernel_get_vring_base(struct vhost_dev *dev,
                                        struct vhost_vring_state *ring)
 {
     return vhost_kernel_call(dev, VHOST_GET_VRING_BASE, ring);
 }
 
-static int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
+int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
                                        struct vhost_vring_file *file)
 {
     return vhost_kernel_call(dev, VHOST_SET_VRING_KICK, file);
 }
 
-static int vhost_kernel_set_vring_call(struct vhost_dev *dev,
+int vhost_kernel_set_vring_call(struct vhost_dev *dev,
                                        struct vhost_vring_file *file)
 {
     return vhost_kernel_call(dev, VHOST_SET_VRING_CALL, file);
@@ -155,13 +155,13 @@  static int vhost_kernel_set_features(struct vhost_dev *dev,
     return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features);
 }
 
-static int vhost_kernel_get_features(struct vhost_dev *dev,
+int vhost_kernel_get_features(struct vhost_dev *dev,
                                      uint64_t *features)
 {
     return vhost_kernel_call(dev, VHOST_GET_FEATURES, features);
 }
 
-static int vhost_kernel_set_owner(struct vhost_dev *dev)
+int vhost_kernel_set_owner(struct vhost_dev *dev)
 {
     return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL);
 }
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 6f6670783f..300b59c172 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -172,4 +172,32 @@  int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
 
 int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);
 
+
+int vhost_kernel_set_log_base(struct vhost_dev *dev, uint64_t base,
+                                     struct vhost_log *log);
+
+int vhost_kernel_set_vring_addr(struct vhost_dev *dev,
+                                       struct vhost_vring_addr *addr);
+
+int vhost_kernel_set_vring_num(struct vhost_dev *dev,
+                                      struct vhost_vring_state *ring);
+
+int vhost_kernel_set_vring_base(struct vhost_dev *dev,
+                                       struct vhost_vring_state *ring);
+
+int vhost_kernel_get_vring_base(struct vhost_dev *dev,
+                                       struct vhost_vring_state *ring);
+
+int vhost_kernel_set_vring_kick(struct vhost_dev *dev,
+                                       struct vhost_vring_file *file);
+
+int vhost_kernel_set_vring_call(struct vhost_dev *dev,
+                                       struct vhost_vring_file *file);
+
+int vhost_kernel_set_owner(struct vhost_dev *dev);
+
+int vhost_kernel_get_features(struct vhost_dev *dev,
+                                     uint64_t *features);
+
+
 #endif /* VHOST_BACKEND_H */