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 457C71FF0AF for ; Thu, 08 Oct 2026 11:47:10 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D34EF213BC; Thu, 08 Oct 2026 11:47:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dualfroz.com; s=dkim; t=1791452815; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=TtHFWn3LwAMusx/BlNtZDv3vxIJbYKKWvDtcRdIwtjY=; b=jMoLkQRYoqiQo+eTwtrW0ytik/t/w+Sv+jQu+oyoG7pVQKMi5Jb0oAArShKmAFMI2sY3l+ y/tZ3uCgHEtRRCEQzuco+AxI/atWYCBlo68nXushnswwyFJJ/wqIv8WITTVnrpjFHqlftm /eqBo5sgI6bPfaASbvIAasY95vYoRWdFHf35yLBwSgTQNWrOPchQIEv4/WuM7zdQBsRYvz fX3ZYREi8mGeBqVFgyKCAHV1hdSaBrb1s3+s48ViDyMtxj6fBVDXv2OmX10/geQNIpstDE uMc4yTfqpILmkjNO/kG3chTITM9MpNc+Y1MswS4we/MmpCPBpuOy+uyumqvW6A== From: Michal Fox To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v2 2/2] fix #4012: migrate: mention snapshots referencing a local ISO image Date: Thu, 8 Oct 2026 09:46:50 +0000 Message-ID: <20261008094650.7-3-me@dualfroz.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261008094650.7-1-me@dualfroz.com> References: <20261008094650.7-1-me@dualfroz.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.134 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy 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: N7QCRQ6GGPG3H2LCZKH2QHA5SW2MXE5K X-Message-ID-Hash: N7QCRQ6GGPG3H2LCZKH2QHA5SW2MXE5K X-MailFrom: me@dualfroz.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: When a VM has no local ISO image attached anymore, but one of its snapshots still references it, migration fails with: can't migrate local disk 'local:iso/debian.iso': local cdrom image which does not tell where the image is coming from, since it is not visible in the current configuration of the VM. Add the names of the snapshots referencing the image to the error in that case, like it is already done for a physical CD/DVD drive. The check for the physical drive now reuses the same hint, which also uses the plural form if more than one snapshot references it. Add a migration test with an ISO image on the 'local' storage that is only referenced in a snapshot. This requires the 'iso' content type for the 'local' storage in the test. Signed-off-by: Michal Fox --- Changes in v2: * add the ISO image to the new $source_other_volumes in the test instead of $source_vdisks (preparatory patch 1/2) * drop 'vmid' from the mocked ISO volume * say "snapshots" in the hint if more than one snapshot references the volume * split overlong line in the test src/PVE/QemuMigrate.pm | 15 ++++----- src/test/run_qemu_migrate_tests.pl | 49 +++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm index 8da6f15d..6605f5d8 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -412,15 +412,16 @@ sub scan_local_volumes { } my $snaprefs = $attr->{referenced_in_snapshot}; + my $snapshot_hint = ''; + if (defined($snaprefs) && !$attr->{is_attached}) { + my $snapnames = join(', ', sort keys %$snaprefs); + my $plural = scalar(keys %$snaprefs) > 1 ? 's' : ''; + $snapshot_hint = " (referenced in snapshot$plural - $snapnames)"; + } if ($attr->{cdrom}) { if ($volid eq 'cdrom') { - my $msg = "can't migrate local cdrom drive"; - if (defined($snaprefs) && !$attr->{is_attached}) { - my $snapnames = join(', ', sort keys %$snaprefs); - $msg .= " (referenced in snapshot - $snapnames)"; - } - &$log_error("$msg\n"); + &$log_error("can't migrate local cdrom drive$snapshot_hint\n"); return; } return if $volid eq 'none'; @@ -475,7 +476,7 @@ sub scan_local_volumes { $local_volumes->{$volid}->{ref} = 'generated'; return; } - die "local cdrom image\n"; + die "local cdrom image$snapshot_hint\n"; } my ($path, $owner) = PVE::Storage::path($storecfg, $volid); diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl index 13962f72..37d52694 100755 --- a/src/test/run_qemu_migrate_tests.pl +++ b/src/test/run_qemu_migrate_tests.pl @@ -37,6 +37,7 @@ my $storage_config = { local => { content => { images => 1, + iso => 1, }, path => "/var/lib/vz", type => "dir", @@ -438,7 +439,18 @@ my $source_vdisks = { # non-image volumes on the source, e.g. ISO images, in the same format as $source_vdisks. They # are only used for the mocked volume_size_info(), because vdisk_list() only returns images. -my $source_other_volumes = {}; +my $source_other_volumes = { + 'local' => [ + { + 'ctime' => 1589439681, + 'format' => 'iso', + 'parent' => undef, + 'size' => 663748608, + 'used' => 663748608, + 'volid' => 'local:iso/debian.iso', + }, + ], +}; my $default_expected_calls_online = { move_config_to_node => 1, @@ -1240,6 +1252,41 @@ my $tests = [ }, }, }, + { + name => '105_local_iso_in_snapshot', + target => 'pve1', + vmid => 105, + vm_status => { + running => 0, + }, + config_patch => { + snapshots => { + ohsnap => { + ide2 => 'local:iso/debian.iso,media=cdrom', + }, + }, + }, + expected_calls => {}, + expect_die => "can't migrate local disk 'local:iso/debian.iso': local cdrom image" + . " (referenced in snapshot - ohsnap)", + expected => { + source_volids => local_volids_for_vm(105), + target_volids => {}, + vm_config => get_patched_config( + 105, + { + snapshots => { + ohsnap => { + ide2 => 'local:iso/debian.iso,media=cdrom', + }, + }, + }, + ), + vm_status => { + running => 0, + }, + }, + }, { name => '105_cdrom', target => 'pve1', -- 2.43.0