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 9804F1FF0E0 for ; Thu, 09 Jul 2026 13:34:03 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 908FB21450; Thu, 09 Jul 2026 13:34:02 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 09 Jul 2026 13:33:26 +0200 Message-Id: From: "Daniel Kral" To: "Daniel Herzig" , Subject: Re: [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs X-Mailer: aerc 0.21.0-147-g43ac7b685014-dirty References: <20260708073135.55426-1-d.herzig@proxmox.com> In-Reply-To: <20260708073135.55426-1-d.herzig@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783596796367 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 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) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EKPMGDXQP5MI73S6XGNL2COUB45DDQYP X-Message-ID-Hash: EKPMGDXQP5MI73S6XGNL2COUB45DDQYP X-MailFrom: d.kral@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: On Wed Jul 8, 2026 at 9:31 AM CEST, Daniel Herzig wrote: > 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=3D7786 Thanks for tackling this and the thorough reproducer in the BZ entry! > > 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; > } > =20 > +# 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) =3D @_; > + my $storecfg =3D $self->{storecfg}; > + my $conf =3D $self->{vmconf}; > + my $vollist =3D PVE::QemuServer::get_vm_volumes($conf); > + for my $volid (@$vollist) { > + my ($sid, $volname) =3D PVE::Storage::parse_volume_id($volid, 1)= ; > + my $scfg =3D PVE::Storage::storage_check_enabled($storecfg, $sid= ); > + eval { PVE::Storage::deactivate_volumes($storecfg, [$volid]); } = if $scfg->{shared}; > + if (my $err =3D $@) { > + $self->log('warn',$err); > + } > + } > +} > + > sub sync_offline_local_volumes { > my ($self) =3D @_; > =20 > @@ -846,6 +866,13 @@ sub phase1 { > $self->handle_replication($vmid); > =20 > $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(); > + } As discussed off-list, I wonder whether this can be a if (!$self->{running}) { my $vollist =3D PVE::QemuServer::get_vm_volumes($conf); PVE::Storage::deactivate_volumes($self->{storecfg}, $vollist); } Just to be sure that there are no active volumes in the case of a offline migration. I wonder whether there are any assumptions in later migration steps where this might break something that I'm not aware of? > + > $self->phase1_remote($vmid) if $self->{opts}->{remote}; > } > =20