From: Daniel Herzig <d.herzig@proxmox.com>
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 [thread overview]
Message-ID: <20260708073135.55426-1-d.herzig@proxmox.com> (raw)
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 <d.herzig@proxmox.com>
---
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
reply other threads:[~2026-07-08 7:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260708073135.55426-1-d.herzig@proxmox.com \
--to=d.herzig@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox