From nobody Thu Sep 24 20:24:34 2026 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=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1789191170; cv=none; d=zohomail.com; s=zohoarc; b=AGD0H15efEbS9e5tzmw9aoAJk/GVG7bbGJJSACaoUA2uo0MBRj+RJ1pPLE3eTbmhOHEbcEkLVZVQgnS6ZE6e1poz+WZoatWlv88r73b5U+7wQmYH1l53qTJ1JPE33xHv4rALGWOJ6NMC1bYr2j5PFwHfY0ufmsrKHhTMkILsIME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789191170; h=Content-Type: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=V2+Epo0c2GY/DFiaKG2Et35W6UvlmmPBMb67zAt4y0E=; b=c48pHHnv5M6DaBfKlX06T+vs1ZFXl/tc93H27MzISo32TT6f9+ZtIwq9eKpq0n34Iu8jznUDPaIu4YDGOOuA/PW6sDy7evxSKYEHjXcD5JwTyhWV++fXrbTT+tZElH2kLJmptfDAXGECX6jR7nmHAVXNnJbz6cMLSum919BMFsU= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789191170084874.8177464910144; Fri, 11 Sep 2026 22:32:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5GLJ-0004Jo-OG; Sat, 12 Sep 2026 01:32:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5GLH-0004JB-8l for qemu-devel@nongnu.org; Sat, 12 Sep 2026 01:31:59 -0400 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5GLE-0003Ss-Dn for qemu-devel@nongnu.org; Sat, 12 Sep 2026 01:31:58 -0400 Received: from h183.csg.ci.i.u-tokyo.ac.jp (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 68C5VLEv094585 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 12 Sep 2026 14:31:26 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=V2+Epo0c2GY/DFiaKG2Et35W6UvlmmPBMb67zAt4y0E=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1789191086; v=1; b=bbGLps/Qad5QVa27vkyocSztx2Axev3ZmUdksvCpvws7bm2OtPTnOGMVsDVpxLRg +bV7pziNSRL1tACf/5TGe+ZyhW2dLmTldhlj8vC4wj+Y68uIFFzm1hoSSYmrGgLl ktDLsL4vklHWKGL2DtjD2fGBPORyjOb9IiP+7prFhhpdPnznCyn6GHRr0B1g06gz ytmFGdQtuoQ0jJtgdUsSRyvllHJfT/B8I2zAYwd9C/6zhCZ9yxZsIX3xqQPX+njS FfbD7j9ee/dpNGivgGEIbv/H9JArT6ETCMr53x0+04jVZNTKtIT0ScXkk8xW+0Tq 6ucAm3W0R6FjZZTOcadmdQ== From: Akihiko Odaki Date: Sat, 12 Sep 2026 14:31:14 +0900 Subject: [PATCH 1/2] hw/tpm: Block CPR with unsupported CRB chunk migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260912-xen-v1-1-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> References: <20260912-xen-v1-0-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260912-xen-v1-0-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: xen-devel@lists.xenproject.org, Stefan Berger , "Michael S. Tsirkin" , Stefano Garzarella , Paolo Bonzini , Fam Zheng , Peter Xu , Fabiano Rosas , Richard Henderson , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1377; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=Xb9shzDcgBjih+DLOzkq3JaxRgPplJIoucYMwzbkpXU=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9aSx8tfX17v99lB6lLvj7OeL2c8ri77/m32no3K25NPv vPdU/Q7uqOUhUGMi0FWTJElpWg3t0Z07afChPgWmDmsTCBDGLg4BWAiZT8Y/llGGG+bNbPm2KT7 z1NOqxze4CLt3bL/0Au1jKYElh/Xw18wMiw7M030y3tOi437Fu1Vcfv4P3/1LavsvdOPrfQty75 81okRAA== X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C 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=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 Precedence: list List-Id: qemu development 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 @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1789191173196158500 Currently only the normal migration mode is blocked with unsupported CRB chunk migration. However, all CPR modes stop the VM before saving. Stopping only freezes an outstanding chunk transaction; it does not clear it. tpm_crb_pre_save() waits for the backend request to finish but may leave command_buffer and response_buffer with some state. Those fields are then omitted when allow_chunk_migration is false. CPR preserves guest RAM or selected kernel resources, not these GByteArray heap objects. Block the CPR modes too. Fixes: a8aa1b220c71 ("hw/tpm: Add support for VM migration with TPM CRB chu= nking") Signed-off-by: Akihiko Odaki Reviewed-by: Stefan Berger --- hw/tpm/tpm_crb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c index 54fa2042b5a8..943809103b63 100644 --- a/hw/tpm/tpm_crb.c +++ b/hw/tpm/tpm_crb.c @@ -482,7 +482,7 @@ static void tpm_crb_realize(DeviceState *dev, Error **e= rrp) error_setg(&s->migration_blocker, "The tpm-crb device does not support chunk migration wi= th " "machine version less than 11.1"); - ret =3D migrate_add_blocker_normal(&s->migration_blocker, errp); + ret =3D migrate_add_blocker(&s->migration_blocker, errp); if (ret < 0) { return; } --=20 2.55.0 From nobody Thu Sep 24 20:24:34 2026 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=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp ARC-Seal: i=1; a=rsa-sha256; t=1789191170; cv=none; d=zohomail.com; s=zohoarc; b=fZEUPj2VvJHUfDOhLwJGvulOUzJoY13/BH6W8YoMH25hZ9/dl4Auq1mwNQD6TV4HBHQI+q6oqjgy5Qw1RNtKt1/iFMXY5HjjGh+2KJEUkdvk17rNPjE7Zbmt0ZNveQeS+/PPOAtppKWjZfr9IKsvXprCs9J/D59XPMofjTP51Tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789191170; h=Content-Type: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=T/CGC5xQGtpJ5PIPu8I7Kewaed70y4BXZ3JJ8mGqF2o=; b=bHAC2N/ouGmjsEcj0Kv5F0Id4cCOLq1kpkbOwiPAQMt7wz/u3XvQcN9NpkeEbx8WRXvq/F1xVitxFfJdaxTJwMfh2G4kBFWpp1tSKRscjQuxeKqHdAY5MXBganpKEj4k0GS+9/eTvbUqeDVcYh7qg6oURUOpkjd3epfZ2Gi2ASs= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789191170123510.1549658070463; Fri, 11 Sep 2026 22:32:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x5GLK-0004KI-Kk; Sat, 12 Sep 2026 01:32:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5GLH-0004JK-QR for qemu-devel@nongnu.org; Sat, 12 Sep 2026 01:31:59 -0400 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x5GLE-0003Sj-Do for qemu-devel@nongnu.org; Sat, 12 Sep 2026 01:31:59 -0400 Received: from h183.csg.ci.i.u-tokyo.ac.jp (h183.csg.ci.i.u-tokyo.ac.jp [133.11.54.183]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 68C5VLEw094585 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 12 Sep 2026 14:31:26 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=T/CGC5xQGtpJ5PIPu8I7Kewaed70y4BXZ3JJ8mGqF2o=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1789191086; v=1; b=jOG0FM3i/kY/f7kLcrzwvW3eT/voCvaEmA6Re33WMwhF4zWWIRSJ0Wv0N1ijceN+ bzofF60TM+MqKVQmX4dKq5kBq4zJhPq64beA6UrzhzZnbPS01RkRVGVRQh6IGK6U xiytSJJe6726/w8aJURimI8k0gxbe505JbDCHfZMzv2xFolr0uwzDkChQ3LFZQmP /PaBPZUYNjSXt533b7vi4ZXxCQmPXj/CeSILHaCe+J92LkLVanJQM8rBuoeh2IYV a2Rgj7QZCyYgE5w0xHWzg/9ePkJM2ishK00KNdjg6SnmuhJouGf9LEsGemu0ipw/ U0dpL4AIPPn1XPOKy1X2yw== From: Akihiko Odaki Date: Sat, 12 Sep 2026 14:31:15 +0900 Subject: [PATCH 2/2] migration: Implement Xen migration blocker MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260912-xen-v1-2-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> References: <20260912-xen-v1-0-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260912-xen-v1-0-ebd6a2aa519f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: xen-devel@lists.xenproject.org, Stefan Berger , "Michael S. Tsirkin" , Stefano Garzarella , Paolo Bonzini , Fam Zheng , Peter Xu , Fabiano Rosas , Richard Henderson , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=11911; i=odaki@rsg.ci.i.u-tokyo.ac.jp; h=from:subject:message-id; bh=yiLScjw61D3kqJnGcGtWox7Oi1fmhO7kMyl411nKI1M=; b=owGbwMvMwCWmMbc20y1CyJDxtFoSQ9aSxyvqj1Zublss8vSd5239rLBd17U+xZeEG5zbskmlc HuzAktLRykLgxgXg6yYIktK0W5ujejaT4UJ8S0wc1iZQIYwcHEKwEQWfWRkuPvgvnD3/YgJqif9 r+jE2zD77L/9sD87cXI5t7bA9GQmJUaGt/3eAUeiluR/eXl07i7dfZ9n8i583rB8vr2k6pVYuUs FrAA= X-Developer-Key: i=odaki@rsg.ci.i.u-tokyo.ac.jp; a=openpgp; fpr=AEDC03C9AF734F2EC26A7BFFA4BAEAA73536753C 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=lists1p.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 Precedence: list List-Id: qemu development 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 @rsg.ci.i.u-tokyo.ac.jp) X-ZM-MESSAGEID: 1789191173272158500 xen-save-devices-state saves device VMState outside QEMU's normal migration-mode machinery, so it currently ignores migration blockers. Add a separate blocker class for this command. Blockers registered with migrate_add_blocker() or migrate_add_blocker_internal() now include this class. Existing mode-specific blocker masks remain unchanged, except that vhost-scsi's default blocker now covers normal migration and Xen device-state saving. Its CPR exemption assumes that the replacement QEMU runs on the same host and not concurrently with the old QEMU; Xen save and restore do not guarantee those conditions. Users can set migratable=3Dtrue when shared storage or orchestrator-migrated target state makes migration safe. Fixes: a7ae8355b446 ("Introduce "xen-save-devices-state"") Signed-off-by: Akihiko Odaki --- include/migration/blocker.h | 10 ++++++- include/qemu/accel.h | 2 +- migration/migration.h | 2 ++ accel/accel-system.c | 25 +++++++++++++----- hw/scsi/vhost-scsi.c | 5 +++- migration/migration.c | 63 ++++++++++++++++++++++++++++++++++++++---= ---- migration/savevm.c | 4 +++ system/vl.c | 9 ++++--- 8 files changed, 99 insertions(+), 21 deletions(-) diff --git a/include/migration/blocker.h b/include/migration/blocker.h index 80b75ad5cbdb..0fbaaac83ce8 100644 --- a/include/migration/blocker.h +++ b/include/migration/blocker.h @@ -16,6 +16,14 @@ =20 #include "qapi/qapi-types-migration.h" =20 +/** + * define MIG_XEN - identifier for Xen migration + * + * Xen migration is distinct from those expressed with &typedef MigMode. + * Use this for migration blockers that affect Xen. + */ +#define MIG_XEN MIG_MODE__MAX + /** * @migrate_add_blocker - prevent all modes of migration from proceeding * @@ -80,7 +88,7 @@ int migrate_add_blocker_normal(Error **reasonp, Error **e= rrp); * * @reasonp - address of an error to be returned whenever migration is att= empted * - * @modes - the migration modes to be blocked, a bit set of MigMode + * @modes - the migration modes to be blocked, a bit set of MigMode and %M= IG_XEN * * @errp - [out] The reason (if any) we cannot block migration right now. * diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 6f65f1cb89a0..b6b456a82fc3 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -47,7 +47,7 @@ const char *current_accel_name(void); =20 void accel_init_interfaces(AccelClass *ac); =20 -int accel_init_machine(AccelState *accel, MachineState *ms); +int accel_init_machine(AccelState *accel, MachineState *ms, Error **errp); =20 /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); diff --git a/migration/migration.h b/migration/migration.h index 683bc7bdd521..f53fdb2df107 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -568,7 +568,9 @@ void migration_start_incoming(void); int migration_call_notifiers(MigrationEventType type, Error **errp); =20 int migrate_init(MigrationState *s, Error **errp); +bool enforce_only_migratable(Error **errp); bool migration_is_blocked(Error **errp); +bool xen_migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); bool migration_postcopy_is_alive(MigrationStatus state); diff --git a/accel/accel-system.c b/accel/accel-system.c index 1325b23864c8..75a691cb3cfe 100644 --- a/accel/accel-system.c +++ b/accel/accel-system.c @@ -26,7 +26,9 @@ #include "qemu/osdep.h" #include "qemu/accel.h" #include "qom/compat-properties.h" +#include "qapi/error.h" #include "qapi/qapi-commands-accelerator.h" +#include "migration/migration.h" #include "monitor/monitor.h" #include "monitor/hmp.h" #include "hw/core/boards.h" @@ -37,20 +39,31 @@ #include "qemu/error-report.h" #include "accel-internal.h" =20 -int accel_init_machine(AccelState *accel, MachineState *ms) +int accel_init_machine(AccelState *accel, MachineState *ms, Error **errp) { AccelClass *acc =3D ACCEL_GET_CLASS(accel); int ret; ms->accelerator =3D accel; *(acc->allowed) =3D true; + + if (!enforce_only_migratable(errp)) { + ret =3D -EACCES; + goto fail; + } + ret =3D acc->init_machine(accel, ms); if (ret < 0) { - ms->accelerator =3D NULL; - *(acc->allowed) =3D false; - object_unref(OBJECT(accel)); - } else { - object_set_accelerator_compat_props(acc->compat_props); + error_setg(errp, "%s", strerror(-ret)); + goto fail; } + + object_set_accelerator_compat_props(acc->compat_props); + return ret; + +fail: + ms->accelerator =3D NULL; + *(acc->allowed) =3D false; + object_unref(OBJECT(accel)); return ret; } =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 657403cad011..f9847b5e7096 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -262,12 +262,15 @@ static void vhost_scsi_realize(DeviceState *dev, Erro= r **errp) } =20 if (!vsc->migratable) { + unsigned int modes =3D BIT(MIG_MODE_NORMAL) | BIT(MIG_XEN); + error_setg(&vsc->migration_blocker, "vhost-scsi does not support migration in all cases. " "When external environment supports it (Orchestrator migra= tes " "target SCSI device state or use shared storage over netwo= rk), " "set 'migratable' property to true to enable migration."); - if (migrate_add_blocker_normal(&vsc->migration_blocker, errp) < 0)= { + if (migrate_add_blocker_modes(&vsc->migration_blocker, + modes, errp) < 0) { goto free_virtio; } } diff --git a/migration/migration.c b/migration/migration.c index d0b864a76066..c177dc52a1c1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -23,6 +23,7 @@ #include "system/runstate.h" #include "system/system.h" #include "system/cpu-throttle.h" +#include "system/xen.h" #include "ram.h" #include "migration/cpr.h" #include "migration/global_state.h" @@ -94,7 +95,8 @@ enum mig_rp_message_type { static MigrationState *current_migration; static MigrationIncomingState *current_incoming; =20 -static GSList *migration_blockers[MIG_MODE__MAX]; +static GSList *migration_blockers[MIG_MODE__MAX + 1]; +static bool enforcing_only_migratable; =20 static bool migration_object_check(MigrationState *ms, Error **errp); static bool migration_switchover_start(MigrationState *s, Error **errp); @@ -1760,15 +1762,22 @@ static bool is_busy(Error **reasonp, Error **errp) return false; } =20 +static void propagate_disallowed_blocker(Error **errp, Error **reasonp) +{ + error_propagate_prepend(errp, *reasonp, + "disallowing migration blocker " + "(--only-migratable) for: "); + *reasonp =3D NULL; +} + static bool is_only_migratable(Error **reasonp, unsigned modes, Error **er= rp) { + unsigned mode =3D xen_enabled() ? MIG_XEN : MIG_MODE_NORMAL; + ERRP_GUARD(); =20 - if (only_migratable && (modes & BIT(MIG_MODE_NORMAL))) { - error_propagate_prepend(errp, *reasonp, - "disallowing migration blocker " - "(--only-migratable) for: "); - *reasonp =3D NULL; + if (enforcing_only_migratable && (modes & BIT(mode))) { + propagate_disallowed_blocker(errp, reasonp); return true; } return false; @@ -1776,7 +1785,7 @@ static bool is_only_migratable(Error **reasonp, unsig= ned modes, Error **errp) =20 static int add_blockers(Error **reasonp, unsigned modes, Error **errp) { - for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + for (MigMode mode =3D 0; mode < ARRAY_SIZE(migration_blockers); mode++= ) { if (modes & BIT(mode)) { assert(g_slist_index(migration_blockers[mode], *reasonp) =3D=3D -1); @@ -1809,7 +1818,7 @@ int migrate_add_blocker_modes(Error **reasonp, unsign= ed modes, Error **errp) =20 int migrate_add_blocker_internal(Error **reasonp, Error **errp) { - unsigned modes =3D BIT(MIG_MODE__MAX) - 1; + unsigned modes =3D BIT(ARRAY_SIZE(migration_blockers)) - 1; =20 if (is_busy(reasonp, errp)) { return -EBUSY; @@ -1820,7 +1829,7 @@ int migrate_add_blocker_internal(Error **reasonp, Err= or **errp) void migrate_del_blocker(Error **reasonp) { if (*reasonp) { - for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + for (MigMode mode =3D 0; mode < ARRAY_SIZE(migration_blockers); mo= de++) { migration_blockers[mode] =3D g_slist_remove(migration_blockers= [mode], *reasonp); } @@ -1948,6 +1957,26 @@ void qmp_migrate_pause(Error **errp) "during postcopy-active or postcopy-recover state"); } =20 +bool enforce_only_migratable(Error **errp) +{ + unsigned mode =3D xen_enabled() ? MIG_XEN : MIG_MODE_NORMAL; + GSList *blockers =3D migration_blockers[mode]; + Error *reason; + + if (!only_migratable) { + return true; + } + + if (blockers) { + reason =3D error_copy(blockers->data); + propagate_disallowed_blocker(errp, &reason); + return false; + } + + enforcing_only_migratable =3D true; + return true; +} + bool migration_is_blocked(Error **errp) { GSList *blockers =3D migration_blockers[migrate_mode()]; @@ -1964,6 +1993,22 @@ bool migration_is_blocked(Error **errp) return false; } =20 +bool xen_migration_is_blocked(Error **errp) +{ + GSList *blockers =3D migration_blockers[MIG_XEN]; + + if (qemu_savevm_state_blocked(errp)) { + return true; + } + + if (blockers) { + error_propagate(errp, error_copy(blockers->data)); + return true; + } + + return false; +} + /* Returns true if continue to migrate, or false if error detected */ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp) { diff --git a/migration/savevm.c b/migration/savevm.c index 4b590ea672d2..4e5e1af1b202 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3418,6 +3418,10 @@ void qmp_xen_save_devices_state(const char *filename= , bool has_live, bool live, int saved_vm_running; int ret; =20 + if (xen_migration_is_blocked(errp)) { + return; + } + if (!has_live) { /* live default to true so old version of Xen tool stack can have a * successful live migration */ diff --git a/system/vl.c b/system/vl.c index 9bd7664b85c7..21fa810637c3 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2392,6 +2392,7 @@ static int accelerator_set_property(void *opaque, =20 static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **= errp) { + Error *local_err =3D NULL; bool *p_init_failed =3D opaque; const char *acc =3D qemu_opt_get(opts, "accel"); AccelClass *ac =3D accel_find(acc); @@ -2418,10 +2419,12 @@ static int do_configure_accelerator(void *opaque, Q= emuOpts *opts, Error **errp) accel, &error_fatal); =20 - ret =3D accel_init_machine(accel, current_machine); + ret =3D accel_init_machine(accel, current_machine, &local_err); if (ret < 0) { - if (!qtest_with_kvm || ret !=3D -ENOENT) { - error_report("failed to initialize %s: %s", acc, strerror(-ret= )); + if (qtest_with_kvm && ret =3D=3D -ENOENT) { + error_free(local_err); + } else { + error_reportf_err(local_err, "failed to initialize %s: ", acc); } goto bad; } --=20 2.55.0