public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
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	[thread overview]
Message-ID: <20261127134637.140854-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261127134637.140854-1-f.ebner@proxmox.com>

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 <f.ebner@proxmox.com>
---
 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





  parent reply	other threads:[~2026-11-27 13:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 13:45 [PATCH-SERIES qemu-server 00/10] restore: check permissions up-front Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 01/10] restore: vma: rename variable for storage configuration Fiona Ebner
2026-11-27 13:45 ` Fiona Ebner [this message]
2026-11-27 13:45 ` [PATCH qemu-server 03/10] restore: introduce dedicated module Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 04/10] restore: move helper for cleaning up target to module Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 05/10] restore: move helper for parsing backup device hints " Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 06/10] restore: move helpers to deactivate and destroy volumes " Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 07/10] restore: move helpers to check identity and write config " Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 08/10] restore: check permissions up-front Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 09/10] restore: extract common helper for preparing new configuration Fiona Ebner
2026-11-27 13:45 ` [PATCH qemu-server 10/10] restore: prepare new config before modifying the target Fiona Ebner

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=20261127134637.140854-3-f.ebner@proxmox.com \
    --to=f.ebner@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