From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9F4C61FF0B4 for ; Fri, 27 Nov 2026 14:46:48 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5F86B2170C; Fri, 27 Nov 2026 14:46:45 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 02/10] restore: skip non-main config sections Date: Fri, 27 Nov 2026 14:45:26 +0100 Message-ID: <20261127134637.140854-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127134637.140854-1-f.ebner@proxmox.com> References: <20261127134637.140854-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795787200600 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.245 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 4QKVUDYD26N2Y2WFKJVW4I6VQKG7ROH7 X-Message-ID-Hash: 4QKVUDYD26N2Y2WFKJVW4I6VQKG7ROH7 X-MailFrom: f.ebner@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: This extends af288d9b ("restore: drop pending changes from the config of the backup") to all non-main sections and to parse_backup_hints(). A vzdump backup is supposed to only include the main section and a stray snapshot section would not match up with the state of the restored volume, which is fresh without any snapshots. Signed-off-by: Fiona Ebner --- src/PVE/QemuServer.pm | 12 ++++++++++-- src/test/restore-config-expected/160.conf | 6 +----- src/test/restore-config-input/160.conf | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index a26faa3d..9af86902 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -6562,6 +6562,7 @@ my $parse_backup_hints = sub { }; my $virtdev_hash = {}; + my $main_section_finished; while (defined(my $line = <$fh>)) { if ($line =~ m/^\#qmdump\#map:(\S+):(\S+):(\S*):(\S*):$/) { my ($virtdev, $devname, $storeid, $format) = ($1, $2, $3, $4); @@ -6583,6 +6584,11 @@ my $parse_backup_hints = sub { $check_storage->($storeid, $scfg); # permission and content type check $virtdev_hash->{$virtdev} = $devinfo->{$devname}; + } elsif ($main_section_finished) { + next; + } elsif ($line =~ m/^\[([^\]]*)\]\s*$/) { + warn "detected backup configuration with unexpected $1 section - skipping it\n"; + $main_section_finished = 1; } elsif ($line =~ m/^((?:ide|sata|scsi)\d+):\s*(.*)\s*$/) { my $virtdev = $1; my $drive = parse_drive($virtdev, $2); @@ -6656,10 +6662,12 @@ sub restore_update_config_line { # vzdump never archives pending changes, and a pending change of a crafted backup would neither # be checked against the privileges of the user nor be visible before the next start applies it + # vzdump also never archives special sections or snapshots, so skip them as well. if ($line =~ m/^\[([^\]]*)\]\s*$/) { - $cookie->{'in-pending-section'} = $1 =~ m/^PENDING$/i; + warn "detected backup configuration with unexpected $1 section - skipping it\n"; + $cookie->{'finished-main-section'} = 1; } - return '' if $cookie->{'in-pending-section'}; + return '' if $cookie->{'finished-main-section'}; return '' if $line =~ m/^\#qmdump\#/; return '' if $line =~ m/^\#vzdump\#/; diff --git a/src/test/restore-config-expected/160.conf b/src/test/restore-config-expected/160.conf index 148f9a76..c334c89e 100644 --- a/src/test/restore-config-expected/160.conf +++ b/src/test/restore-config-expected/160.conf @@ -1,11 +1,7 @@ -# pending changes of a crafted backup are dropped, other sections stay +# non-main sections of a crafted backup are dropped boot: order=scsi0 cores: 1 memory: 512 name: crafted scsi0: target:160/vm-160-disk-0.qcow2,size=4G -[snap] -cores: 2 -memory: 512 -snaptime: 1700000000 diff --git a/src/test/restore-config-input/160.conf b/src/test/restore-config-input/160.conf index b3f41450..3c0aa141 100644 --- a/src/test/restore-config-input/160.conf +++ b/src/test/restore-config-input/160.conf @@ -1,4 +1,4 @@ -# pending changes of a crafted backup are dropped, other sections stay +# non-main sections of a crafted backup are dropped boot: order=scsi0 cores: 1 memory: 512 -- 2.47.3