From nobody Fri Dec 19 16:02:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1658309646; cv=none; d=zohomail.com; s=zohoarc; b=iAdO7Or7qXB6YVkmeeIhaxSKcNYvEnPAM1NoMTpq2v8d8sjesVG1PA+LfmjcclqSYjMjfgGpv1lMgJHy0YZneZbsCfwddg4C/3emTB7edaELOA26hRiBQxDmCKRiQq5F7Rl2uabSEjCheu+ZjJBcWB+XIm9uS348yTGj39dHabA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658309646; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tmjRmXnw+cXbZH6Ts4daW4hP6dk+7aXVj7OFJ+hv2qE=; b=l4Zb/vM/9M4UkgdykDpra6TJRnX7mCdUvPBvt/kuyGZXtBpqyywogrlRxDwIVoERnqFYgTapsfjhAqQcCBjQhJ8QOel3anY+Q7BprHZrFu5hjaHG1+Cw4aQ5Z9vLTw6QUL/0MJ5ufaDyWsW0BUDBHhYDEi4Se3shHC+7bYp1tEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658309646419630.0600816075395; Wed, 20 Jul 2022 02:34:06 -0700 (PDT) Received: from localhost ([::1]:45628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oE65l-0003Rm-6H for importer@patchew.org; Wed, 20 Jul 2022 05:34:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oE5dC-0000cM-O9 for qemu-devel@nongnu.org; Wed, 20 Jul 2022 05:04:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oE5d7-0001Va-Iu for qemu-devel@nongnu.org; Wed, 20 Jul 2022 05:04:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-D7qtrMGpMtq6BhO8bVBlOQ-1; Wed, 20 Jul 2022 05:04:20 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34EA18001EA; Wed, 20 Jul 2022 09:04:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-110.pek2.redhat.com [10.72.13.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0C88492C3B; Wed, 20 Jul 2022 09:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658307863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tmjRmXnw+cXbZH6Ts4daW4hP6dk+7aXVj7OFJ+hv2qE=; b=cha3sHh2+94a4By6VP9cSGqa1V5btht7VC6wzz0eJqEZt7fZqmKCGXj/CMDQaUwZyzUjdq tK+dXyClpJ8+2AbpgSBSgARg2vL1OkgExtjU086MfSx9LrbCRczccGHJHEm9qyaNGhFLgS Ra33/O1gfePY6hOi//g2PjBCtCEwVA0= X-MC-Unique: D7qtrMGpMtq6BhO8bVBlOQ-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?UTF-8?q?Eugenio=20P=C3=A9rez?= , "Michael S . Tsirkin" , Jason Wang Subject: [PULL V2 20/25] vdpa: Add device migration blocker Date: Wed, 20 Jul 2022 17:03:08 +0800 Message-Id: <20220720090313.55169-21-jasowang@redhat.com> In-Reply-To: <20220720090313.55169-1-jasowang@redhat.com> References: <20220720090313.55169-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658309647569100001 From: Eugenio P=C3=A9rez Since the vhost-vdpa device is exposing _F_LOG, adding a migration blocker = if it uses CVQ. However, qemu is able to migrate simple devices with no CVQ as long as they use SVQ. To allow it, add a placeholder error to vhost_vdpa, and only add to vhost_dev when used. vhost_dev machinery place the migration blocker if needed. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 15 +++++++++++++++ include/hw/virtio/vhost-vdpa.h | 1 + 2 files changed, 16 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index beaaa70..291cd19 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; } =20 + if (v->migration_blocker) { + int r =3D migrate_add_blocker(v->migration_blocker, &err); + if (unlikely(r < 0)) { + return false; + } + } + for (i =3D 0; i < v->shadow_vqs->len; ++i) { VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); @@ -1064,6 +1072,10 @@ err: vhost_svq_stop(svq); } =20 + if (v->migration_blocker) { + migrate_del_blocker(v->migration_blocker); + } + return false; } =20 @@ -1083,6 +1095,9 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *de= v) } } =20 + if (v->migration_blocker) { + migrate_del_blocker(v->migration_blocker); + } return true; } =20 diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 1111d85..d10a893 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; --=20 2.7.4