public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Daniel Kral" <d.kral@proxmox.com>
To: "Daniel Herzig" <d.herzig@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs
Date: Thu, 09 Jul 2026 13:33:26 +0200	[thread overview]
Message-ID: <DJU0AT5RY86Q.2WOYRYI2SOJ4C@proxmox.com> (raw)
In-Reply-To: <20260708073135.55426-1-d.herzig@proxmox.com>

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=7786

Thanks for tackling this and the thorough reproducer in the BZ entry!

>
> 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();
> +    }

As discussed off-list, I wonder whether this can be a

    if (!$self->{running}) {
        my $vollist = 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};
>  }
>  




  reply	other threads:[~2026-07-09 11:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  7:31 [PATCH qemu-server] fix #7786: migrate: deactivate shared storage volumes of offline VMs Daniel Herzig
2026-07-09 11:33 ` Daniel Kral [this message]
2026-07-09 13:30   ` Daniel Herzig
2026-07-09 14:20     ` Daniel Kral
2026-07-09 14:54       ` Daniel Herzig

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=DJU0AT5RY86Q.2WOYRYI2SOJ4C@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal