From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkIZ4-0005zZ-9t for qemu-devel@nongnu.org; Thu, 08 Oct 2015 17:17:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkIYz-0007FL-72 for qemu-devel@nongnu.org; Thu, 08 Oct 2015 17:17:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkIYz-0007FG-25 for qemu-devel@nongnu.org; Thu, 08 Oct 2015 17:17:21 -0400 Date: Fri, 9 Oct 2015 00:17:16 +0300 From: "Michael S. Tsirkin" Message-ID: <1444338957-15293-12-git-send-email-mst@redhat.com> References: <1444338957-15293-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1444338957-15293-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 11/25] vhost-user: add a migration blocker List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?us-ascii?B?PT9VVEYtOD9xP01hcmMtQW5kcj1DMz1BOT0yMEx1cmVhdT89?= From: Marc-Andr=E9 Lureau If VHOST_USER_PROTOCOL_F_LOG_SHMFD is not announced, block vhost-user migration. The blocker is removed in vhost_dev_cleanup(). Signed-off-by: Marc-Andr=E9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 9 +++++++++ hw/virtio/vhost.c | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index cf14e38..f1edd04 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -15,6 +15,7 @@ #include "qemu/error-report.h" #include "qemu/sockets.h" #include "exec/ram_addr.h" +#include "migration/migration.h" =20 #include #include @@ -442,6 +443,14 @@ static int vhost_user_init(struct vhost_dev *dev, vo= id *opaque) } } =20 + if (dev->migration_blocker =3D=3D NULL && + !virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_LOG_SHMFD)) { + error_setg(&dev->migration_blocker, + "Migration disabled: vhost-user backend lacks " + "VHOST_USER_PROTOCOL_F_LOG_SHMFD feature."); + } + return 0; } =20 diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index d1c0367..554e49d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -944,6 +944,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, uint64_t features; int i, r; =20 + hdev->migration_blocker =3D NULL; + if (vhost_set_backend_type(hdev, backend_type) < 0) { close((uintptr_t)opaque); return -1; @@ -987,12 +989,18 @@ int vhost_dev_init(struct vhost_dev *hdev, void *op= aque, .eventfd_del =3D vhost_eventfd_del, .priority =3D 10 }; - hdev->migration_blocker =3D NULL; - if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { - error_setg(&hdev->migration_blocker, - "Migration disabled: vhost lacks VHOST_F_LOG_ALL feat= ure."); + + if (hdev->migration_blocker =3D=3D NULL) { + if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { + error_setg(&hdev->migration_blocker, + "Migration disabled: vhost lacks VHOST_F_LOG_ALL = feature."); + } + } + + if (hdev->migration_blocker !=3D NULL) { migrate_add_blocker(hdev->migration_blocker); } + hdev->mem =3D g_malloc0(offsetof(struct vhost_memory, regions)); hdev->n_mem_sections =3D 0; hdev->mem_sections =3D NULL; --=20 MST