diff mbox

[v2,6/9] vhost: use variable arguments for vhost_call()

Message ID 1438105003-29501-7-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 28, 2015, 5:36 p.m. UTC
It is useful to pass extra arguments to the funtions, for
various backend needs.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/virtio/vhost-backend.c         | 4 ++--
 hw/virtio/vhost-user.c            | 4 ++--
 include/hw/virtio/vhost-backend.h | 6 ++++--
 3 files changed, 8 insertions(+), 6 deletions(-)

Comments

Leandro Dorileo Aug. 1, 2015, 2:47 a.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

Hi André,

> It is useful to pass extra arguments to the funtions, for
> various backend needs.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/virtio/vhost-backend.c         | 4 ++--
>  hw/virtio/vhost-user.c            | 4 ++--
>  include/hw/virtio/vhost-backend.h | 6 ++++--
>  3 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> index 4d68a27..7255089 100644
> --- a/hw/virtio/vhost-backend.c
> +++ b/hw/virtio/vhost-backend.c
> @@ -14,8 +14,8 @@
>  
>  #include <sys/ioctl.h>
>  
> -static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request,
> -                             void *arg)
> +static int vhost_kernel_call(struct vhost_dev *dev,
> +                             unsigned long int request, void *arg, ...)



I Couldn't see in your set where you change vhost_kernel_call() implementation or
make any use of this change.

Regards...
Marc-André Lureau Aug. 3, 2015, 11:03 a.m. UTC | #2
Hi

On Sat, Aug 1, 2015 at 4:47 AM,  <l@dorileo.org> wrote:
>> diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
>> index 4d68a27..7255089 100644
>> --- a/hw/virtio/vhost-backend.c
>> +++ b/hw/virtio/vhost-backend.c
>> @@ -14,8 +14,8 @@
>>
>>  #include <sys/ioctl.h>
>>
>> -static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request,
>> -                             void *arg)
>> +static int vhost_kernel_call(struct vhost_dev *dev,
>> +                             unsigned long int request, void *arg, ...)
>
>
>
> I Couldn't see in your set where you change vhost_kernel_call() implementation or
> make any use of this change.
>

That's expected, the change is necessary for vhost-user only atm. They both use
the same callback, so vhost-kernel must be changed too and ignore the
extra args.

cheers
diff mbox

Patch

diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 4d68a27..7255089 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -14,8 +14,8 @@ 
 
 #include <sys/ioctl.h>
 
-static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int request,
-                             void *arg)
+static int vhost_kernel_call(struct vhost_dev *dev,
+                             unsigned long int request, void *arg, ...)
 {
     int fd = (uintptr_t) dev->opaque;
 
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 4993b63..8b6d7e7 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -190,8 +190,8 @@  static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
             0 : -1;
 }
 
-static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
-        void *arg)
+static int vhost_user_call(struct vhost_dev *dev,
+                           unsigned long int request, void *arg, ...)
 {
     VhostUserMsg msg;
     VhostUserRequest msg_request;
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index e472f29..36fa0f7 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -11,6 +11,8 @@ 
 #ifndef VHOST_BACKEND_H_
 #define VHOST_BACKEND_H_
 
+#include <stdarg.h>
+
 typedef enum VhostBackendType {
     VHOST_BACKEND_TYPE_NONE = 0,
     VHOST_BACKEND_TYPE_KERNEL = 1,
@@ -20,8 +22,8 @@  typedef enum VhostBackendType {
 
 struct vhost_dev;
 
-typedef int (*vhost_call)(struct vhost_dev *dev, unsigned long int request,
-             void *arg);
+typedef int (*vhost_call)(struct vhost_dev *dev,
+                          unsigned long int request, void *arg, ...);
 typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque);
 typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev);