Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker if
it uses CVQ.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
include/hw/virtio/vhost-vdpa.h | 1 +
hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 1111d85643..d10a89303e 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
bool shadow_vqs_enabled;
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
+ Error *migration_blocker;
GPtrArray *shadow_vqs;
const VhostShadowVirtqueueOps *shadow_vq_ops;
void *shadow_vq_ops_opaque;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index beaaa7049a..795ed5a049 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -20,6 +20,7 @@
#include "hw/virtio/vhost-shadow-virtqueue.h"
#include "hw/virtio/vhost-vdpa.h"
#include "exec/address-spaces.h"
+#include "migration/blocker.h"
#include "qemu/cutils.h"
#include "qemu/main-loop.h"
#include "cpu.h"
@@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
return true;
}
+ if (v->migration_blocker) {
+ int r = migrate_add_blocker(v->migration_blocker, &err);
+ if (unlikely(r < 0)) {
+ goto err_migration_blocker;
+ }
+ }
+
for (i = 0; i < v->shadow_vqs->len; ++i) {
VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
@@ -1064,6 +1072,9 @@ err:
vhost_svq_stop(svq);
}
+err_migration_blocker:
+ error_reportf_err(err, "Cannot setup SVQ %u: ", i);
+
return false;
}
@@ -1083,6 +1094,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
}
}
+ if (v->migration_blocker) {
+ migrate_del_blocker(v->migration_blocker);
+ }
return true;
}
--
2.31.1
On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Since the vhost-vdpa device is exposing _F_LOG,
I may miss something but I think it doesn't?
Note that the features were fetched from the vDPA parent.
Thanks
> adding a migration blocker if
> it uses CVQ.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> include/hw/virtio/vhost-vdpa.h | 1 +
> hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
> index 1111d85643..d10a89303e 100644
> --- a/include/hw/virtio/vhost-vdpa.h
> +++ b/include/hw/virtio/vhost-vdpa.h
> @@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
> bool shadow_vqs_enabled;
> /* IOVA mapping used by the Shadow Virtqueue */
> VhostIOVATree *iova_tree;
> + Error *migration_blocker;
> GPtrArray *shadow_vqs;
> const VhostShadowVirtqueueOps *shadow_vq_ops;
> void *shadow_vq_ops_opaque;
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index beaaa7049a..795ed5a049 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -20,6 +20,7 @@
> #include "hw/virtio/vhost-shadow-virtqueue.h"
> #include "hw/virtio/vhost-vdpa.h"
> #include "exec/address-spaces.h"
> +#include "migration/blocker.h"
> #include "qemu/cutils.h"
> #include "qemu/main-loop.h"
> #include "cpu.h"
> @@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
> return true;
> }
>
> + if (v->migration_blocker) {
> + int r = migrate_add_blocker(v->migration_blocker, &err);
> + if (unlikely(r < 0)) {
> + goto err_migration_blocker;
> + }
> + }
> +
> for (i = 0; i < v->shadow_vqs->len; ++i) {
> VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
> VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
> @@ -1064,6 +1072,9 @@ err:
> vhost_svq_stop(svq);
> }
>
> +err_migration_blocker:
> + error_reportf_err(err, "Cannot setup SVQ %u: ", i);
> +
> return false;
> }
>
> @@ -1083,6 +1094,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
> }
> }
>
> + if (v->migration_blocker) {
> + migrate_del_blocker(v->migration_blocker);
> + }
> return true;
> }
>
> --
> 2.31.1
>
On Fri, Jul 15, 2022 at 6:03 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > Since the vhost-vdpa device is exposing _F_LOG,
>
> I may miss something but I think it doesn't?
>
It's at vhost_vdpa_get_features. As long as SVQ is enabled, it's
exposing VHOST_F_LOG_ALL.
Thanks!
> Note that the features were fetched from the vDPA parent.
>
> Thanks
>
> > adding a migration blocker if
> > it uses CVQ.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> > include/hw/virtio/vhost-vdpa.h | 1 +
> > hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
> > 2 files changed, 15 insertions(+)
> >
> > diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
> > index 1111d85643..d10a89303e 100644
> > --- a/include/hw/virtio/vhost-vdpa.h
> > +++ b/include/hw/virtio/vhost-vdpa.h
> > @@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
> > bool shadow_vqs_enabled;
> > /* IOVA mapping used by the Shadow Virtqueue */
> > VhostIOVATree *iova_tree;
> > + Error *migration_blocker;
> > GPtrArray *shadow_vqs;
> > const VhostShadowVirtqueueOps *shadow_vq_ops;
> > void *shadow_vq_ops_opaque;
> > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > index beaaa7049a..795ed5a049 100644
> > --- a/hw/virtio/vhost-vdpa.c
> > +++ b/hw/virtio/vhost-vdpa.c
> > @@ -20,6 +20,7 @@
> > #include "hw/virtio/vhost-shadow-virtqueue.h"
> > #include "hw/virtio/vhost-vdpa.h"
> > #include "exec/address-spaces.h"
> > +#include "migration/blocker.h"
> > #include "qemu/cutils.h"
> > #include "qemu/main-loop.h"
> > #include "cpu.h"
> > @@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
> > return true;
> > }
> >
> > + if (v->migration_blocker) {
> > + int r = migrate_add_blocker(v->migration_blocker, &err);
> > + if (unlikely(r < 0)) {
> > + goto err_migration_blocker;
> > + }
> > + }
> > +
> > for (i = 0; i < v->shadow_vqs->len; ++i) {
> > VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
> > VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
> > @@ -1064,6 +1072,9 @@ err:
> > vhost_svq_stop(svq);
> > }
> >
> > +err_migration_blocker:
> > + error_reportf_err(err, "Cannot setup SVQ %u: ", i);
> > +
> > return false;
> > }
> >
> > @@ -1083,6 +1094,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
> > }
> > }
> >
> > + if (v->migration_blocker) {
> > + migrate_del_blocker(v->migration_blocker);
> > + }
> > return true;
> > }
> >
> > --
> > 2.31.1
> >
>
On Fri, Jul 15, 2022 at 1:40 PM Eugenio Perez Martin
<eperezma@redhat.com> wrote:
>
> On Fri, Jul 15, 2022 at 6:03 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote:
> > >
> > > Since the vhost-vdpa device is exposing _F_LOG,
> >
> > I may miss something but I think it doesn't?
> >
>
> It's at vhost_vdpa_get_features. As long as SVQ is enabled, it's
> exposing VHOST_F_LOG_ALL.
Ok, so this needs to be specified in the change log. But I'm kind of
confused here, we do want to allow migration to work so why we disable
it?
Thanks
>
> Thanks!
>
> > Note that the features were fetched from the vDPA parent.
> >
> > Thanks
> >
> > > adding a migration blocker if
> > > it uses CVQ.
> > >
> > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > > ---
> > > include/hw/virtio/vhost-vdpa.h | 1 +
> > > hw/virtio/vhost-vdpa.c | 14 ++++++++++++++
> > > 2 files changed, 15 insertions(+)
> > >
> > > diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
> > > index 1111d85643..d10a89303e 100644
> > > --- a/include/hw/virtio/vhost-vdpa.h
> > > +++ b/include/hw/virtio/vhost-vdpa.h
> > > @@ -35,6 +35,7 @@ typedef struct vhost_vdpa {
> > > bool shadow_vqs_enabled;
> > > /* IOVA mapping used by the Shadow Virtqueue */
> > > VhostIOVATree *iova_tree;
> > > + Error *migration_blocker;
> > > GPtrArray *shadow_vqs;
> > > const VhostShadowVirtqueueOps *shadow_vq_ops;
> > > void *shadow_vq_ops_opaque;
> > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > index beaaa7049a..795ed5a049 100644
> > > --- a/hw/virtio/vhost-vdpa.c
> > > +++ b/hw/virtio/vhost-vdpa.c
> > > @@ -20,6 +20,7 @@
> > > #include "hw/virtio/vhost-shadow-virtqueue.h"
> > > #include "hw/virtio/vhost-vdpa.h"
> > > #include "exec/address-spaces.h"
> > > +#include "migration/blocker.h"
> > > #include "qemu/cutils.h"
> > > #include "qemu/main-loop.h"
> > > #include "cpu.h"
> > > @@ -1022,6 +1023,13 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev)
> > > return true;
> > > }
> > >
> > > + if (v->migration_blocker) {
> > > + int r = migrate_add_blocker(v->migration_blocker, &err);
> > > + if (unlikely(r < 0)) {
> > > + goto err_migration_blocker;
> > > + }
> > > + }
> > > +
> > > for (i = 0; i < v->shadow_vqs->len; ++i) {
> > > VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i);
> > > VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
> > > @@ -1064,6 +1072,9 @@ err:
> > > vhost_svq_stop(svq);
> > > }
> > >
> > > +err_migration_blocker:
> > > + error_reportf_err(err, "Cannot setup SVQ %u: ", i);
> > > +
> > > return false;
> > > }
> > >
> > > @@ -1083,6 +1094,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
> > > }
> > > }
> > >
> > > + if (v->migration_blocker) {
> > > + migrate_del_blocker(v->migration_blocker);
> > > + }
> > > return true;
> > > }
> > >
> > > --
> > > 2.31.1
> > >
> >
>
On Fri, Jul 15, 2022 at 10:51 AM Jason Wang <jasowang@redhat.com> wrote: > > On Fri, Jul 15, 2022 at 1:40 PM Eugenio Perez Martin > <eperezma@redhat.com> wrote: > > > > On Fri, Jul 15, 2022 at 6:03 AM Jason Wang <jasowang@redhat.com> wrote: > > > > > > On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote: > > > > > > > > Since the vhost-vdpa device is exposing _F_LOG, > > > > > > I may miss something but I think it doesn't? > > > > > > > It's at vhost_vdpa_get_features. As long as SVQ is enabled, it's > > exposing VHOST_F_LOG_ALL. > > Ok, so this needs to be specified in the change log. I tried to add the entry in the changelog but I don't have the permission to do so. Something like "Add new experimental x-svq option to migrate simple vhost-vdpa net devices without CVQ"? Thanks!
On Fri, Jul 15, 2022 at 10:51 AM Jason Wang <jasowang@redhat.com> wrote: > > On Fri, Jul 15, 2022 at 1:40 PM Eugenio Perez Martin > <eperezma@redhat.com> wrote: > > > > On Fri, Jul 15, 2022 at 6:03 AM Jason Wang <jasowang@redhat.com> wrote: > > > > > > On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote: > > > > > > > > Since the vhost-vdpa device is exposing _F_LOG, > > > > > > I may miss something but I think it doesn't? > > > > > > > It's at vhost_vdpa_get_features. As long as SVQ is enabled, it's > > exposing VHOST_F_LOG_ALL. > > Ok, so this needs to be specified in the change log. Got it, I'll write some note. > But I'm kind of > confused here, we do want to allow migration to work so why we disable > it? > With x-svq parameter, migration of simple devices with no cvq "is possible". It has intrinsic problems like can't emit the gratuitous arp but it's possible and traffic can continue. But devices with cvq require to restore the state at the destination. That part is not implemented, so it's blocked at the moment. In the immediate future not all cases (as "net features") will be available: net/vhost-net.c (or virtio-net.c?) needs to know how to inject the state at the destination to restore the guest visible configuration. It's simple code, but it needs to be developed. So migration blocker is kept for these features. Hopefully, we will reach a point where all features supported by virtio-net.c will be supported, but the right thing to do is to merge basic ones first. Thanks!
On Fri, Jul 15, 2022 at 11:05 AM Eugenio Perez Martin <eperezma@redhat.com> wrote: > > On Fri, Jul 15, 2022 at 10:51 AM Jason Wang <jasowang@redhat.com> wrote: > > > > On Fri, Jul 15, 2022 at 1:40 PM Eugenio Perez Martin > > <eperezma@redhat.com> wrote: > > > > > > On Fri, Jul 15, 2022 at 6:03 AM Jason Wang <jasowang@redhat.com> wrote: > > > > > > > > On Fri, Jul 15, 2022 at 12:32 AM Eugenio Pérez <eperezma@redhat.com> wrote: > > > > > > > > > > Since the vhost-vdpa device is exposing _F_LOG, > > > > > > > > I may miss something but I think it doesn't? > > > > > > > > > > It's at vhost_vdpa_get_features. As long as SVQ is enabled, it's > > > exposing VHOST_F_LOG_ALL. > > > > Ok, so this needs to be specified in the change log. > > Got it, I'll write some note. > > > But I'm kind of > > confused here, we do want to allow migration to work so why we disable > > it? > > > Adding here: Without the x-svq parameter, migration is disabled unless the actual vdpa device backend supports _F_LOG_ALL by itself. There is no such thing in the Linux kernel at the moment. > With x-svq parameter, migration of simple devices with no cvq "is > possible". It has intrinsic problems like can't emit the gratuitous > arp but it's possible and traffic can continue. > > But devices with cvq require to restore the state at the destination. > That part is not implemented, so it's blocked at the moment. > > In the immediate future not all cases (as "net features") will be > available: net/vhost-net.c (or virtio-net.c?) needs to know how to > inject the state at the destination to restore the guest visible > configuration. It's simple code, but it needs to be developed. So > migration blocker is kept for these features. Hopefully, we will reach > a point where all features supported by virtio-net.c will be > supported, but the right thing to do is to merge basic ones first. > > Thanks!
© 2016 - 2026 Red Hat, Inc.