From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C5DBD1FF164 for ; Wed, 11 Sep 2024 16:09:18 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7E8D310181; Wed, 11 Sep 2024 16:09:18 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Wed, 11 Sep 2024 16:09:10 +0200 Message-Id: <20240911140910.190670-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.059 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [RFC v2 qemu] savevm-async: reuse migration blocker check for snapshots/hibernation X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Same rationale as with upstream QEMU commit 5aaac46793 ("migration: savevm: consult migration blockers"), migration and (async) snapshot are essentially the same operation and thus snapshot also needs to check for migration blockers. For example, this catches passed-through PCI devices, where the driver does not support migration. However, the commit notes: > There is really no difference between live migration and savevm, except > that savevm does not require bdrv_invalidate_cache to be implemented > by all disks. However, it is unlikely that savevm is used with anything > except qcow2 disks, so the penalty is small and worth the improvement > in catching bad usage of savevm. and for Proxmox VE, suspend-to-disk with VMDK does use savevm-async and would be broken by simply using migration_is_blocked(). To keep this working, introduce a new helper that filters blockers with the prefix used by the VMDK migration blocker. The function qemu_savevm_state_blocked() is called as part of savevm_async_is_blocked() so no check is lost with this patch. The helper is declared in migration/migration.c to be able to access the 'migration_blockers'. The VMDK blocker message is declared via a '#define', because using a 'const char*' led to the linker to complain about multiple declarations. The message does not include the reference to the block node anymore, but it would've just been a generated one like '#block334' in any case, which didn't help users identify the VMDK disk before the change either. Note, this also "breaks" snapshot and hibernate with VNC clipboard by preventing it. Previously, this would "work", because the Proxmox VE API has no check yet, but the clipboard will be broken after rollback, in the sense that it cannot be used anymore, not just lost contents. So some users might consider adding the check here a breaking change even if it's technically correct to prevent snapshot and hibernate with VNC clipboard. But other users might rightfully complain about broken clipboard. And again, the check also prevents blockers from passed-through PCI devices, etc. so it seems worth tolerating that breakage. Signed-off-by: Fiona Ebner --- Changes in v2: * hard-code blocker message to get a conflict if it changes upstream. * avoid making helper more general than it needs to be (had a parameter for matching the prefix of blocker messages). block/vmdk.c | 4 +--- include/migration/blocker.h | 2 ++ migration/migration.c | 24 ++++++++++++++++++++++++ migration/migration.h | 1 + migration/savevm-async.c | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 3b82979fdf..eb15109620 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1403,9 +1403,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, qemu_co_mutex_init(&s->lock); /* Disable migration when VMDK images are used */ - error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " - "does not support live migration", - bdrv_get_device_or_node_name(bs)); + error_setg(&s->migration_blocker, "%s", MIGRATION_BLOCKER_VMDK); ret = migrate_add_blocker_normal(&s->migration_blocker, errp); if (ret < 0) { goto fail; diff --git a/include/migration/blocker.h b/include/migration/blocker.h index a687ac0efe..f36bfb2df1 100644 --- a/include/migration/blocker.h +++ b/include/migration/blocker.h @@ -18,6 +18,8 @@ #define MIG_MODE_ALL MIG_MODE__MAX +#define MIGRATION_BLOCKER_VMDK "The vmdk format used by a disk does not support live migration" + /** * @migrate_add_blocker - prevent all modes of migration from proceeding * diff --git a/migration/migration.c b/migration/migration.c index b8d7e471a4..b18c3720b2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1913,6 +1913,30 @@ bool migration_is_blocked(Error **errp) return false; } +bool savevm_async_is_blocked(Error **errp) +{ + GSList *blockers = migration_blockers[migrate_mode()]; + + if (qemu_savevm_state_blocked(errp)) { + return true; + } + + /* + * The limitation for VMDK images only applies to live-migration, not + * snapshots, see commit 5aaac46793 ("migration: savevm: consult migration + * blockers"). + */ + while (blockers) { + if (strcmp(error_get_pretty(blockers->data), MIGRATION_BLOCKER_VMDK)) { + error_propagate(errp, error_copy(blockers->data)); + return true; + } + blockers = g_slist_next(blockers); + } + + return false; +} + /* Returns true if continue to migrate, or false if error detected */ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, bool resume, Error **errp) diff --git a/migration/migration.h b/migration/migration.h index 8045e39c26..8834050ba8 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -485,6 +485,7 @@ int migration_call_notifiers(MigrationState *s, MigrationEventType type, int migrate_init(MigrationState *s, Error **errp); bool migration_is_blocked(Error **errp); +bool savevm_async_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); bool migration_postcopy_is_alive(int state); diff --git a/migration/savevm-async.c b/migration/savevm-async.c index fb4e8ea689..93b1044f77 100644 --- a/migration/savevm-async.c +++ b/migration/savevm-async.c @@ -363,7 +363,7 @@ void qmp_savevm_start(const char *statefile, Error **errp) return; } - if (qemu_savevm_state_blocked(errp)) { + if (savevm_async_is_blocked(errp)) { return; } -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel