From nobody Sat May 18 19:12:35 2024 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=1676556082; cv=none; d=zohomail.com; s=zohoarc; b=LG6gPPJ97AKXezAaVIOBhfvuyY1zqWapVhyRhFsABr3hTasQ8wP9Qd0ElSWg8Ng6pz9yiSQ9gwA7UZ1UPHTTMtVxmXnfuIW3kXMLUXEQoI6P0F6LVZ6QDOlZp8HlB8TAlZ/ih5aTo8lWbU3u7dj38AQiSmQfvNp9uJ9fV1zyA1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676556082; h=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=J8Y3uDi6qCzTP8dnddhcudJnMoTlOL2W73l3D1Arrkc=; b=X6xjazKfRtEVOFW9Hz3LKZeqF97hsM7IisFKDIh+DLx+6UHg+LrgC9H4mi0TqpqUgrrgGp1+l0yb0ONa05lE75VlC4zmaGSpXrAmBNWj23R/UQziAoqmFos/D/a/MBRPow/ICu1DClzXWjls6p/fV2qjBEIpJMygEawmIhITJ7g= 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 1676556081620445.2109948133799; Thu, 16 Feb 2023 06:01:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSeoN-0003ll-81; Thu, 16 Feb 2023 09:00:35 -0500 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 1pSeoK-0003kG-GM for qemu-devel@nongnu.org; Thu, 16 Feb 2023 09:00:32 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSeoI-00038b-N3 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 09:00:32 -0500 Received: from vla1-81430ab5870b.qloud-c.yandex.net (vla1-81430ab5870b.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:35a1:0:640:8143:ab5]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTP id A4AB05FE1E; Thu, 16 Feb 2023 17:00:19 +0300 (MSK) Received: from antonkuchin-nix.yandex-team.ru (unknown [2a02:6b8:b081:7313::1:33]) by vla1-81430ab5870b.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 30mChN0RvGk1-2f3rpAhw; Thu, 16 Feb 2023 17:00:18 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1676556018; bh=J8Y3uDi6qCzTP8dnddhcudJnMoTlOL2W73l3D1Arrkc=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=RkCLxEZTYjnQVii2/xMNaIjSu4IUw95XeKZ1+GiOkYlqxHvwzJLOa9fXZUjI3443D MR3KjG0Wyw6kbQbLUfGXhdh2wLSLgNs5gUGcX6jnqyS0cp9VO7oyO6Sekfk7wuj2Jg 3IBxMslraj4Mtb6an3+wGUjwjP4/vL1ITRaD7zEA= Authentication-Results: vla1-81430ab5870b.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Anton Kuchin To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Markus Armbruster , yc-core@yandex-team.ru, Stefan Hajnoczi , virtio-fs@redhat.com, Eric Blake , Juan Quintela , Paolo Bonzini , Anton Kuchin Subject: [PATCH v2 1/1] vhost-user-fs: add property to allow migration Date: Thu, 16 Feb 2023 16:00:03 +0200 Message-Id: <20230216140003.1103681-2-antonkuchin@yandex-team.ru> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216140003.1103681-1-antonkuchin@yandex-team.ru> References: <20230216140003.1103681-1-antonkuchin@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.72; envelope-from=antonkuchin@yandex-team.ru; helo=forwardcorp1a.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, 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 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: 1676556087754100001 Content-Type: text/plain; charset="utf-8" Now any vhost-user-fs device makes VM unmigratable, that also prevents qemu update without stopping the VM. In most cases that makes sense because qemu has no way to transfer FUSE session state. But it is good to have an option for orchestrator to tune this according to backend capabilities and migration configuration. This patch adds device property 'migration' that is 'none' by default to keep old behaviour but can be set to 'external' to explicitly allow migration with minimal virtio device state in migration stream if daemon has some way to sync FUSE state on src and dst without help from qemu. Signed-off-by: Anton Kuchin Reviewed-by: Juan Quintela --- hw/core/qdev-properties-system.c | 10 +++++++++ hw/virtio/vhost-user-fs.c | 34 ++++++++++++++++++++++++++++- include/hw/qdev-properties-system.h | 1 + include/hw/virtio/vhost-user-fs.h | 1 + qapi/migration.json | 16 ++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index d42493f630..d9b1aa2a5d 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -1143,3 +1143,13 @@ const PropertyInfo qdev_prop_uuid =3D { .set =3D set_uuid, .set_default_value =3D set_default_uuid_auto, }; + +const PropertyInfo qdev_prop_vhost_user_migration_type =3D { + .name =3D "VhostUserMigrationType", + .description =3D "none/external", + .enum_table =3D &VhostUserMigrationType_lookup, + .get =3D qdev_propinfo_get_enum, + .set =3D qdev_propinfo_set_enum, + .set_default_value =3D qdev_propinfo_set_default_value_enum, + .realized_set_allowed =3D true, +}; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 83fc20e49e..e2a5b6cfdf 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -24,6 +24,7 @@ #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" +#include "qapi/qapi-types-migration.h" =20 static const int user_feature_bits[] =3D { VIRTIO_F_VERSION_1, @@ -298,9 +299,36 @@ static struct vhost_dev *vuf_get_vhost(VirtIODevice *v= dev) return &fs->vhost_dev; } =20 +static int vhost_user_fs_pre_save(void *opaque) +{ + VHostUserFS *fs =3D (VHostUserFS *)opaque; + g_autofree char *path =3D object_get_canonical_path(OBJECT(fs)); + + switch (fs->migration_type) { + case VHOST_USER_MIGRATION_TYPE_NONE: + error_report("Migration is blocked by device %s", path); + break; + case VHOST_USER_MIGRATION_TYPE_EXTERNAL: + return 0; + default: + error_report("Migration type '%s' is not supported by device %s", + VhostUserMigrationType_str(fs->migration_type), path); + break; + } + + return -1; +} + static const VMStateDescription vuf_vmstate =3D { .name =3D "vhost-user-fs", - .unmigratable =3D 1, + .minimum_version_id =3D 0, + .version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_UINT8(migration_type, VHostUserFS), + VMSTATE_END_OF_LIST() + }, + .pre_save =3D vhost_user_fs_pre_save, }; =20 static Property vuf_properties[] =3D { @@ -309,6 +337,10 @@ static Property vuf_properties[] =3D { DEFINE_PROP_UINT16("num-request-queues", VHostUserFS, conf.num_request_queues, 1), DEFINE_PROP_UINT16("queue-size", VHostUserFS, conf.queue_size, 128), + DEFINE_PROP_UNSIGNED("migration", VHostUserFS, migration_type, + VHOST_USER_MIGRATION_TYPE_NONE, + qdev_prop_vhost_user_migration_type, + uint8_t), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 0ac327ae60..1a67591590 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -22,6 +22,7 @@ extern const PropertyInfo qdev_prop_audiodev; extern const PropertyInfo qdev_prop_off_auto_pcibar; extern const PropertyInfo qdev_prop_pcie_link_speed; extern const PropertyInfo qdev_prop_pcie_link_width; +extern const PropertyInfo qdev_prop_vhost_user_migration_type; =20 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) diff --git a/include/hw/virtio/vhost-user-fs.h b/include/hw/virtio/vhost-us= er-fs.h index 94c3aaa84e..3ebce77be5 100644 --- a/include/hw/virtio/vhost-user-fs.h +++ b/include/hw/virtio/vhost-user-fs.h @@ -40,6 +40,7 @@ struct VHostUserFS { VirtQueue **req_vqs; VirtQueue *hiprio_vq; int32_t bootindex; + uint8_t migration_type; =20 /*< public >*/ }; diff --git a/qapi/migration.json b/qapi/migration.json index c84fa10e86..ababd605a2 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -2178,3 +2178,19 @@ 'data': { 'job-id': 'str', 'tag': 'str', 'devices': ['str'] } } + +## +# @VhostUserMigrationType: +# +# Type of vhost-user device migration. +# +# @none: Migration is not supported, attempts to migrate with this device +# will be blocked. +# +# @external: Migration stream contains only virtio device state, +# deamon state should be transfered externally by orchestrator. +# +# Since: 8.0 +## +{ 'enum': 'VhostUserMigrationType', + 'data': [ 'none', 'external' ] } --=20 2.37.2