From nobody Fri Nov 14 21:05:44 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1761730928; cv=none; d=zohomail.com; s=zohoarc; b=i/FBjSrq5XzCAQC2u0RGo8RX1yU4Ryq9WHBLJzhxV7l9BdwSvL8xMOBoVOKtKdw1r9KxTuYhTrDhe7PJFn/LrBeInpLlyqwx2adKw9/dl9/ypLEtOkHM2EkkiIm2XlbN1soOODoTZybIx+oEb4XKapDDhcD9VpbA+tmQEEYm/sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761730928; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L3idjeFzpoBa9CNA1EydnK3SilKFwfpI7XQJIuYetWs=; b=QteEWFAboLtT4XAgsldZ7HxgVUDqTvDlVGMKJ36Yd4O9MAD2ueUdmuYRIROobZVhkedTnJb1eXjYSuJvX9Qh5BQ0TWWvpY5uarPoLrAsN7EwskRScTQHAY+yjF0tjofeGNsXRNI5hzHPdEz9gO5UAy3YuG4EZPn7XMC5hq6mjtU= 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 1761730927768645.9773534243698; Wed, 29 Oct 2025 02:42:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vE2gJ-0002Z2-R0; Wed, 29 Oct 2025 05:41:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE2gI-0002Ye-Ai for qemu-devel@nongnu.org; Wed, 29 Oct 2025 05:41:26 -0400 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE2g8-0008TE-KG for qemu-devel@nongnu.org; Wed, 29 Oct 2025 05:41:24 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 35CE9808B7; Wed, 29 Oct 2025 12:41:10 +0300 (MSK) Received: from dtalexundeer-nx.yandex.net (unknown [2a02:6bf:8080:d37::1:31]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id Rea6510FtiE0-W2yEEPnq; Wed, 29 Oct 2025 12:41:09 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1761730869; bh=L3idjeFzpoBa9CNA1EydnK3SilKFwfpI7XQJIuYetWs=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=kRwZUeWL7r5LG/ghvyAV+cNj9FRoye0cZt10L8e5uBDz8DU9+TAK84p8aH7SrzZQF XQXhsVnrAJHZFZMQqFVNjNt20ZBOP9feeQgsRRTPdUyCh5+1kUQoc/6nMW9dcQGik4 znRmMObsL9uCBeSu95Ft722dp2mAovipmagaJemU= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Raphael Norwitz , "Michael S. Tsirkin" , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v2 3/3] vhost-user-blk: support inter-host inflight migration Date: Wed, 29 Oct 2025 14:39:43 +0500 Message-Id: <20251029093939.3251188-4-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251029093939.3251188-1-dtalexundeer@yandex-team.ru> References: <20251029093939.3251188-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1761730935525158500 Content-Type: text/plain; charset="utf-8" During inter-host migration, waiting for disk requests to be drained in the vhost-user backend can incur significant downtime. This can be avoided if QEMU migrates the inflight region in vhost-user-blk. Thus, during the qemu migration, the vhost-user backend can cancel all inflight requests and then, after migration, they will be executed on another host. In vhost_user_blk_stop() on incoming inter-host migration make force_stop = =3D true, so GET_VRING_BASE will not be executed. Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 30 ++++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-blk.h | 1 + 2 files changed, 31 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a8fd90480a..29d4505d24 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -242,6 +242,12 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 + if (s->enable_inflight_region_migration && + !migrate_local_vhost_user_blk() && + runstate_check(RUN_STATE_FINISH_MIGRATE)) { + force_stop =3D true; + } + s->dev.backend_transfer =3D s->dev.backend_transfer || (runstate_check(RUN_STATE_FINISH_MIGRATE) && migrate_local_vhost_user_blk()); @@ -656,6 +662,24 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Virt= IODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_inflight_needed(void *opaque) +{ + struct VHostUserBlk *s =3D opaque; + + return s->enable_inflight_region_migration && + !migrate_local_vhost_user_blk(); +} + +static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { + .name =3D "vhost-user-blk/inflight", + .version_id =3D 1, + .needed =3D vhost_user_blk_inflight_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), + VMSTATE_END_OF_LIST() + }, +}; + static bool vhost_user_blk_pre_incoming(void *opaque, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(opaque); @@ -678,6 +702,10 @@ static const VMStateDescription vmstate_vhost_user_blk= =3D { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_vhost_user_blk_inflight, + NULL + } }; =20 static bool vhost_user_needed(void *opaque) @@ -751,6 +779,8 @@ static const Property vhost_user_blk_properties[] =3D { VIRTIO_BLK_F_WRITE_ZEROES, true), DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk, skip_get_vring_base_on_force_shutdown, false), + DEFINE_PROP_BOOL("enable-inflight-migration", VHostUserBlk, + enable_inflight_region_migration, false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index b06f55fd6f..1556714296 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -52,6 +52,7 @@ struct VHostUserBlk { bool started_vu; =20 bool skip_get_vring_base_on_force_shutdown; + bool enable_inflight_region_migration; =20 bool incoming_backend; }; --=20 2.34.1