Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 697B5EB105A for ; Tue, 10 Mar 2026 14:26:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzy2Y-0000KH-1i; Tue, 10 Mar 2026 10:26:30 -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 1vzy2S-0000E5-LU; Tue, 10 Mar 2026 10:26:24 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzy2Q-0001Bb-DV; Tue, 10 Mar 2026 10:26:24 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 961F087493; Tue, 10 Mar 2026 15:26:11 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, marcandre.lureau@redhat.com, peterx@redhat.com, farosas@suse.de Subject: [PATCH v2] ui/vdagent: add migration blocker when machine version < 10.1 Date: Tue, 10 Mar 2026 15:25:39 +0100 Message-ID: <20260310142552.240877-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773152737132 Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In QEMU 10.1, commit 5d56bff11e ("ui/vdagent: add migration support") added migration support for the vdagent chardev and commit 42000e0013 ("ui/vdagent: remove migration blocker") removed the migration blocker. No compat for older machine versions was added, so migration with pre-10.1 machine version, from a 10.1 binary to a pre-10.1 binary will result in a failure when loading the VM state in the target instance: > Unknown savevm section or instance 'vdagent' 0. Make sure that your > current VM setup matches your saved VM setup, including any > hotplugged devices Add a compat flag to block migration when the machine version is less than 10.1 to avoid this. Cc: qemu-stable@nongnu.org Fixes: 42000e0013 ("ui/vdagent: remove migration blocker") Signed-off-by: Fiona Ebner --- Changes in v2: * rebase on current master, adapting to commit 8c84f31ace ("chardev: .chr_open(): add boolean return value") hw/core/machine.c | 1 + ui/vdagent.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index a14ad05b9a..6cf0e2f404 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -57,6 +57,7 @@ GlobalProperty hw_compat_10_0[] = { { "vfio-pci", "x-migration-load-config-after-iter", "off" }, { "ramfb", "use-legacy-x86-rom", "true"}, { "vfio-pci-nohotplug", "use-legacy-x86-rom", "true" }, + { "chardev-qemu-vdagent", "x-migration-blocked", "true" }, }; const size_t hw_compat_10_0_len = G_N_ELEMENTS(hw_compat_10_0); diff --git a/ui/vdagent.c b/ui/vdagent.c index 5a5e4bf681..bb0c4aa14c 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -6,6 +6,8 @@ #include "qemu/option.h" #include "qemu/units.h" #include "hw/core/qdev.h" +#include "hw/core/qdev-properties.h" +#include "migration/blocker.h" #include "ui/clipboard.h" #include "ui/console.h" #include "ui/input.h" @@ -24,6 +26,10 @@ struct VDAgentChardev { Chardev parent; + /* needed for machine versions < 10.1 when migration was not supported */ + Error *migration_blocker; + bool migration_blocked; + /* config */ bool mouse; bool clipboard; @@ -657,6 +663,12 @@ static bool vdagent_chr_open(Chardev *chr, ChardevBackend *backend, return false; #endif + if (vd->migration_blocked) { + if (migrate_add_blocker(&vd->migration_blocker, errp) != 0) { + return false; + } + } + vd->mouse = VDAGENT_MOUSE_DEFAULT; if (cfg->has_mouse) { vd->mouse = cfg->mouse; @@ -901,6 +913,19 @@ static void vdagent_chr_parse(QemuOpts *opts, ChardevBackend *backend, /* ------------------------------------------------------------------ */ +static bool get_migration_blocked(Object *o, Error **errp) +{ + VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(o); + return vd->migration_blocked; +} + +static void set_migration_blocked(Object *o, bool migration_blocked, + Error **errp) +{ + VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(o); + vd->migration_blocked = migration_blocked; +} + static void vdagent_chr_class_init(ObjectClass *oc, const void *data) { ChardevClass *cc = CHARDEV_CLASS(oc); @@ -910,6 +935,10 @@ static void vdagent_chr_class_init(ObjectClass *oc, const void *data) cc->chr_write = vdagent_chr_write; cc->chr_set_fe_open = vdagent_chr_set_fe_open; cc->chr_accept_input = vdagent_chr_accept_input; + + object_class_property_add_bool(oc, "x-migration-blocked", + get_migration_blocked, + set_migration_blocked); } static int post_load(void *opaque, int version_id) @@ -1064,10 +1093,26 @@ static void vdagent_chr_instance_init(Object *obj) vmstate_register_any(NULL, &vmstate_vdagent, vd); } +static void vdagent_post_init(Object *obj) +{ + VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(obj); + + object_apply_compat_props(obj); + + if (vd->migration_blocked) { + error_setg(&vd->migration_blocker, + "The vdagent chardev doesn't support migration with machine" + " version less than 10.1"); + } +} + static void vdagent_chr_fini(Object *obj) { VDAgentChardev *vd = QEMU_VDAGENT_CHARDEV(obj); + if (vd->migration_blocked) { + migrate_del_blocker(&vd->migration_blocker); + } vdagent_disconnect(vd); if (vd->mouse_hs) { qemu_input_handler_unregister(vd->mouse_hs); @@ -1080,6 +1125,7 @@ static const TypeInfo vdagent_chr_type_info = { .parent = TYPE_CHARDEV, .instance_size = sizeof(VDAgentChardev), .instance_init = vdagent_chr_instance_init, + .instance_post_init = vdagent_post_init, .instance_finalize = vdagent_chr_fini, .class_init = vdagent_chr_class_init, }; -- 2.47.3