From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 07DE51FF13A for ; Wed, 08 Jul 2026 09:31:43 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 11BEF21444; Wed, 08 Jul 2026 09:31:42 +0200 (CEST) From: Daniel Herzig To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs Date: Wed, 8 Jul 2026 09:31:35 +0200 Message-ID: <20260708073135.55426-1-d.herzig@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.570 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: B4U6BHJAUFXN6I56XZKN6GETN43L23SB X-Message-ID-Hash: B4U6BHJAUFXN6I56XZKN6GETN43L23SB X-MailFrom: dherzig@emma.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If non-running VMs with active LVs on shared storage get migrated to another node, these volumes currently stay activated on the source node. This can cause issues on the source node when resizing the volume on the target node [0] after migration. This patch addresses this issue by ensuring volume deactivation on the source node in such cases. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=7786 Signed-off-by: Daniel Herzig --- src/PVE/QemuMigrate.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm index 8da6f15d..bf55b73d 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -710,6 +710,26 @@ sub filter_local_volumes { return @filtered_volids; } +# deactivate shared-storage volumes on source node. +# NOTE: only meant to be called for non-running VMs! +# Active volumes may be present for non-running VMs +# eg after cloning, disk move, or user-intervention. +# For running VMs deactivation is handled separately. +sub deactivate_volumes_on_shared_storage { + my ($self) = @_; + my $storecfg = $self->{storecfg}; + my $conf = $self->{vmconf}; + my $vollist = PVE::QemuServer::get_vm_volumes($conf); + for my $volid (@$vollist) { + my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1); + my $scfg = PVE::Storage::storage_check_enabled($storecfg, $sid); + eval { PVE::Storage::deactivate_volumes($storecfg, [$volid]); } if $scfg->{shared}; + if (my $err = $@) { + $self->log('warn',$err); + } + } +} + sub sync_offline_local_volumes { my ($self) = @_; @@ -846,6 +866,13 @@ sub phase1 { $self->handle_replication($vmid); $self->sync_offline_local_volumes(); + + # make sure that volumes of non-running VMs on shared storage + # are deactivated. + if (! $self->{running}) { + $self->deactivate_volumes_on_shared_storage(); + } + $self->phase1_remote($vmid) if $self->{opts}->{remote}; } -- 2.47.3