diff mbox series

[RFC,v2,5/7] vhost: Add x-vhost-enable-shadow-vq qmp

Message ID 20210209153757.1653598-6-eperezma@redhat.com (mailing list archive)
State New, archived
Headers show
Series vDPA shadow virtqueue - notifications forwarding | expand

Commit Message

Eugenio Perez Martin Feb. 9, 2021, 3:37 p.m. UTC
Command to enable shadow virtqueue looks like:

{ "execute": "x-vhost-enable-shadow-vq", "arguments": { "name": "dev0", "enable": true } }

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 qapi/net.json     | 22 ++++++++++++++++++++++
 hw/virtio/vhost.c |  6 ++++++
 2 files changed, 28 insertions(+)

Comments

Stefan Hajnoczi Feb. 17, 2021, 3:26 p.m. UTC | #1
On Tue, Feb 09, 2021 at 04:37:55PM +0100, Eugenio Pérez wrote:
> diff --git a/qapi/net.json b/qapi/net.json
> index c31748c87f..a1cdffb0f9 100644
> --- a/qapi/net.json
> +++ b/qapi/net.json
> @@ -77,6 +77,28 @@
>  ##
>  { 'command': 'netdev_del', 'data': {'id': 'str'} }
>  
> +##
> +# @x-vhost-enable-shadow-vq:
> +#
> +# Use vhost shadow virtqueue.

Is this command for testing only or do you expect it to be invoked by
libvirt in production? I think the shadow virtqueue can be an internal
QEMU feature that is hidden from management tools.

> +#
> +# @name: the device name of the virtual network adapter
> +#
> +# @enable: true to use he alternate shadow VQ notification path
> +#
> +# Returns: Error if failure, or 'no error' for success
> +#
> +# Since: 6.0

Is this a generic feature for any vhost or vDPA device? If yes, please
replace "virtual network adapter" in the doc comment.

Does this only apply to vhost-net devices? If so, please put "vhost-net"
in the name since there are other non-net vhost devices.

> +#
> +# Example:
> +#
> +# -> { "execute": "x-vhost-enable-shadow-vq", "arguments": {"enable": true} }

Missing "name" field?
Eugenio Perez Martin Feb. 17, 2021, 6:47 p.m. UTC | #2
On Wed, Feb 17, 2021 at 4:26 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> On Tue, Feb 09, 2021 at 04:37:55PM +0100, Eugenio Pérez wrote:
> > diff --git a/qapi/net.json b/qapi/net.json
> > index c31748c87f..a1cdffb0f9 100644
> > --- a/qapi/net.json
> > +++ b/qapi/net.json
> > @@ -77,6 +77,28 @@
> >  ##
> >  { 'command': 'netdev_del', 'data': {'id': 'str'} }
> >
> > +##
> > +# @x-vhost-enable-shadow-vq:
> > +#
> > +# Use vhost shadow virtqueue.
>
> Is this command for testing only or do you expect it to be invoked by
> libvirt in production? I think the shadow virtqueue can be an internal
> QEMU feature that is hidden from management tools.
>

I think shadow virtqueue should kick in automatically when live
migration is triggered and the vhost device does not have _F_LOG too.

Maybe something like "prefer shadow vq to vhost logging" could be
exposed, but it is not a thing we have to figure now.

> > +#
> > +# @name: the device name of the virtual network adapter
> > +#
> > +# @enable: true to use he alternate shadow VQ notification path
> > +#
> > +# Returns: Error if failure, or 'no error' for success
> > +#
> > +# Since: 6.0
>
> Is this a generic feature for any vhost or vDPA device? If yes, please
> replace "virtual network adapter" in the doc comment.
>
> Does this only apply to vhost-net devices? If so, please put "vhost-net"
> in the name since there are other non-net vhost devices.

Right, thanks for the catch!

>
> > +#
> > +# Example:
> > +#
> > +# -> { "execute": "x-vhost-enable-shadow-vq", "arguments": {"enable": true} }
>
> Missing "name" field?

Yes, I will fix the example in future revisions.

Thanks!
Eugenio Perez Martin Feb. 18, 2021, 6:35 p.m. UTC | #3
On Wed, Feb 17, 2021 at 7:47 PM Eugenio Perez Martin
<eperezma@redhat.com> wrote:
>
> On Wed, Feb 17, 2021 at 4:26 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > On Tue, Feb 09, 2021 at 04:37:55PM +0100, Eugenio Pérez wrote:
> > > diff --git a/qapi/net.json b/qapi/net.json
> > > index c31748c87f..a1cdffb0f9 100644
> > > --- a/qapi/net.json
> > > +++ b/qapi/net.json
> > > @@ -77,6 +77,28 @@
> > >  ##
> > >  { 'command': 'netdev_del', 'data': {'id': 'str'} }
> > >
> > > +##
> > > +# @x-vhost-enable-shadow-vq:
> > > +#
> > > +# Use vhost shadow virtqueue.
> >
> > Is this command for testing only or do you expect it to be invoked by
> > libvirt in production? I think the shadow virtqueue can be an internal
> > QEMU feature that is hidden from management tools.
> >
>
> I think shadow virtqueue should kick in automatically when live
> migration is triggered and the vhost device does not have _F_LOG too.
>
> Maybe something like "prefer shadow vq to vhost logging" could be
> exposed, but it is not a thing we have to figure now.
>
> > > +#
> > > +# @name: the device name of the virtual network adapter
> > > +#
> > > +# @enable: true to use he alternate shadow VQ notification path
> > > +#
> > > +# Returns: Error if failure, or 'no error' for success
> > > +#
> > > +# Since: 6.0
> >
> > Is this a generic feature for any vhost or vDPA device? If yes, please
> > replace "virtual network adapter" in the doc comment.
> >
> > Does this only apply to vhost-net devices? If so, please put "vhost-net"
> > in the name since there are other non-net vhost devices.
>
> Right, thanks for the catch!
>

Moreover, the command should not be in net.json. However, I don't see
a generic virtio/vhost file to add the command.

> >
> > > +#
> > > +# Example:
> > > +#
> > > +# -> { "execute": "x-vhost-enable-shadow-vq", "arguments": {"enable": true} }
> >
> > Missing "name" field?
>
> Yes, I will fix the example in future revisions.
>
> Thanks!
diff mbox series

Patch

diff --git a/qapi/net.json b/qapi/net.json
index c31748c87f..a1cdffb0f9 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -77,6 +77,28 @@ 
 ##
 { 'command': 'netdev_del', 'data': {'id': 'str'} }
 
+##
+# @x-vhost-enable-shadow-vq:
+#
+# Use vhost shadow virtqueue.
+#
+# @name: the device name of the virtual network adapter
+#
+# @enable: true to use he alternate shadow VQ notification path
+#
+# Returns: Error if failure, or 'no error' for success
+#
+# Since: 6.0
+#
+# Example:
+#
+# -> { "execute": "x-vhost-enable-shadow-vq", "arguments": {"enable": true} }
+#
+##
+{ 'command': 'x-vhost-enable-shadow-vq',
+  'data': {'name': 'str', 'enable': 'bool'},
+  'if': 'defined(CONFIG_VHOST_KERNEL)' }
+
 ##
 # @NetLegacyNicOptions:
 #
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 5d0c817b8f..8fbf14385e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -15,6 +15,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/qapi-commands-net.h"
 #include "hw/virtio/vhost.h"
 #include "qemu/atomic.h"
 #include "qemu/range.h"
@@ -1833,3 +1834,8 @@  int vhost_net_set_backend(struct vhost_dev *hdev,
 
     return -1;
 }
+
+void qmp_x_vhost_enable_shadow_vq(const char *name, bool enable, Error **errp)
+{
+    error_setg(errp, "Shadow virtqueue still not implemented");
+}