diff mbox series

[v3,13/13] RFC: add explicit can_migrate to vhost_user_backend_dev_init()

Message ID 20190208112357.31615-14-marcandre.lureau@redhat.com
State New
Headers show
Series vhost-user-backend & vhost-user-input | expand

Commit Message

Marc-André Lureau Feb. 8, 2019, 11:23 a.m. UTC
In general, there is not much support for migrating a vhost-user slave
process. Many virtio devices however implement vmsd, and the
vhost-user instances (as child objects) may be migrated.

Since there is no other support at this point, the slave is assumed to
be state less (outside of VM state), or using a migration method
outside of qemu migration stream.

Since this is not well specified, add a common blocker for the
VhostUserBackend users (vhost-user-input and upcoming gpu will use
it).

RFC since I am not sure that's what Michael had in mind when
requesting such blocker.

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

Comments

Marc-André Lureau Feb. 15, 2019, 3:28 p.m. UTC | #1
Michael,

On Fri, Feb 8, 2019 at 12:34 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> In general, there is not much support for migrating a vhost-user slave
> process. Many virtio devices however implement vmsd, and the
> vhost-user instances (as child objects) may be migrated.
>
> Since there is no other support at this point, the slave is assumed to
> be state less (outside of VM state), or using a migration method
> outside of qemu migration stream.
>
> Since this is not well specified, add a common blocker for the
> VhostUserBackend users (vhost-user-input and upcoming gpu will use
> it).
>
> RFC since I am not sure that's what Michael had in mind when
> requesting such blocker.

Could you look at that proposal?

thanks

>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/sysemu/vhost-user-backend.h | 2 +-
>  backends/vhost-user.c               | 7 ++++++-
>  hw/input/vhost-user-input.c         | 2 +-
>  3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/include/sysemu/vhost-user-backend.h b/include/sysemu/vhost-user-backend.h
> index 60f811cae7..feb331288f 100644
> --- a/include/sysemu/vhost-user-backend.h
> +++ b/include/sysemu/vhost-user-backend.h
> @@ -53,7 +53,7 @@ struct VhostUserBackend {
>  };
>
>  int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
> -                                unsigned nvqs, Error **errp);
> +                                unsigned nvqs, bool can_migrate, Error **errp);
>  void vhost_user_backend_start(VhostUserBackend *b);
>  void vhost_user_backend_stop(VhostUserBackend *b);
>
> diff --git a/backends/vhost-user.c b/backends/vhost-user.c
> index 289dbd9e6d..7fa52d2f47 100644
> --- a/backends/vhost-user.c
> +++ b/backends/vhost-user.c
> @@ -30,7 +30,7 @@ ioeventfd_enabled(void)
>
>  int
>  vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
> -                            unsigned nvqs, Error **errp)
> +                            unsigned nvqs, bool can_migrate, Error **errp)
>  {
>      int ret;
>
> @@ -49,6 +49,11 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
>      b->dev.nvqs = nvqs;
>      b->dev.vqs = g_new(struct vhost_virtqueue, nvqs);
>
> +    if (!can_migrate && !b->dev.migration_blocker) {
> +        error_setg(&b->dev.migration_blocker,
> +                   "Migration disabled: vhost-user device can't migrate");
> +    }
> +
>      ret = vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
>      if (ret < 0) {
>          error_setg_errno(errp, -ret, "vhost initialization failed");
> diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c
> index 2ea1e50ab7..58b1684156 100644
> --- a/hw/input/vhost-user-input.c
> +++ b/hw/input/vhost-user-input.c
> @@ -24,7 +24,7 @@ static void vhost_input_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>
> -    if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, errp) == -1) {
> +    if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, false, errp) == -1) {
>          return;
>      }
>
> --
> 2.20.1.519.g8feddda32c
>
>
Gerd Hoffmann Feb. 21, 2019, 9:39 a.m. UTC | #2
> Since this is not well specified, add a common blocker for the
> VhostUserBackend users (vhost-user-input and upcoming gpu will use
> it).
> 
> RFC since I am not sure that's what Michael had in mind when
> requesting such blocker.

vmstate_vhost_input blocks migration too (via .unmigratable = 1).
One way to block live migration is enough.

I think it makes sense to do it per device.  virtio-input doesn't carry
much state, so live-migrating it shouldn't be that difficuilt.
virtio-gpu will be harder ...

cheers,
  Gerd
diff mbox series

Patch

diff --git a/include/sysemu/vhost-user-backend.h b/include/sysemu/vhost-user-backend.h
index 60f811cae7..feb331288f 100644
--- a/include/sysemu/vhost-user-backend.h
+++ b/include/sysemu/vhost-user-backend.h
@@ -53,7 +53,7 @@  struct VhostUserBackend {
 };
 
 int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
-                                unsigned nvqs, Error **errp);
+                                unsigned nvqs, bool can_migrate, Error **errp);
 void vhost_user_backend_start(VhostUserBackend *b);
 void vhost_user_backend_stop(VhostUserBackend *b);
 
diff --git a/backends/vhost-user.c b/backends/vhost-user.c
index 289dbd9e6d..7fa52d2f47 100644
--- a/backends/vhost-user.c
+++ b/backends/vhost-user.c
@@ -30,7 +30,7 @@  ioeventfd_enabled(void)
 
 int
 vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
-                            unsigned nvqs, Error **errp)
+                            unsigned nvqs, bool can_migrate, Error **errp)
 {
     int ret;
 
@@ -49,6 +49,11 @@  vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
     b->dev.nvqs = nvqs;
     b->dev.vqs = g_new(struct vhost_virtqueue, nvqs);
 
+    if (!can_migrate && !b->dev.migration_blocker) {
+        error_setg(&b->dev.migration_blocker,
+                   "Migration disabled: vhost-user device can't migrate");
+    }
+
     ret = vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
     if (ret < 0) {
         error_setg_errno(errp, -ret, "vhost initialization failed");
diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c
index 2ea1e50ab7..58b1684156 100644
--- a/hw/input/vhost-user-input.c
+++ b/hw/input/vhost-user-input.c
@@ -24,7 +24,7 @@  static void vhost_input_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, errp) == -1) {
+    if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, false, errp) == -1) {
         return;
     }