public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs
@ 2026-07-08  7:31 Daniel Herzig
  0 siblings, 0 replies; only message in thread
From: Daniel Herzig @ 2026-07-08  7:31 UTC (permalink / raw)
  To: pve-devel

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




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-08  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08  7:31 [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs Daniel Herzig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal