all lists on 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 10/10] restore: prepare new config before modifying the target
Date: Fri, 27 Nov 2026 14:45:34 +0100	[thread overview]
Message-ID: <20261127134637.140854-11-f.ebner@proxmox.com> (raw)
In-Reply-To: <20261127134637.140854-1-f.ebner@proxmox.com>

In particular, check the permissions before recording a pending uid,
before removing the replication state and before restoring the
firewall configuration.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer.pm | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 9bfb6906..7ee1ec17 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -6862,6 +6862,10 @@ sub restore_proxmox_backup_archive {
         $param = [$pbs_backup_name, "qemu-server.conf", $cfgfn];
         PVE::Storage::PBSPlugin::run_raw_client_cmd($scfg, $storeid, $cmd, $param);
 
+        ($new_conf, $virtdev_hash) = restore_prepare_new_config(
+            $rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $options,
+        );
+
         PVE::QemuServer::Restore::check_identity(
             $vmid, PVE::Tools::file_get_contents($cfgfn), $options,
         );
@@ -6876,10 +6880,6 @@ sub restore_proxmox_backup_archive {
             restore_firewall_config($vmid, $firewall_config_fn);
         }
 
-        ($new_conf, $virtdev_hash) = restore_prepare_new_config(
-            $rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $options,
-        );
-
         # fixme: rate limit?
 
         # create empty/temp config
@@ -7030,22 +7030,22 @@ sub restore_external_archive {
         my $data = $backup_provider->archive_get_guest_config($volname)
             or die "backup provider failed to extract guest configuration\n";
 
+        PVE::Tools::file_set_contents($cfgfn, $data);
+
+        ($new_conf, $virtdev_hash) = restore_prepare_new_config(
+            $rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $options,
+        );
+
         PVE::QemuServer::Restore::check_identity($vmid, $data, $options);
 
         $options->{progress}->{'target-changed'} = 1;
         PVE::ReplicationState::delete_guest_states($vmid);
 
-        PVE::Tools::file_set_contents($cfgfn, $data);
-
         if ($data = $backup_provider->archive_get_firewall_config($volname)) {
             PVE::Tools::file_set_contents($firewall_config_fn, $data);
             restore_firewall_config($vmid, $firewall_config_fn);
         }
 
-        ($new_conf, $virtdev_hash) = restore_prepare_new_config(
-            $rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $options,
-        );
-
         # create empty/temp config
         PVE::QemuServer::Restore::write_config(
             $vmid, { memory => 128, lock => 'create' }, $options,
@@ -7434,6 +7434,9 @@ sub restore_vma_archive {
     my $print_devmap = sub {
         my $cfgfn = "$tmpdir/qemu-server.conf";
 
+        ($new_conf, $virtdev_hash) =
+            restore_prepare_new_config($rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $opts);
+
         PVE::QemuServer::Restore::check_identity(
             $vmid, PVE::Tools::file_get_contents($cfgfn), $opts,
         );
@@ -7441,10 +7444,6 @@ sub restore_vma_archive {
         $opts->{progress}->{'target-changed'} = 1;
         PVE::ReplicationState::delete_guest_states($vmid);
 
-        ($new_conf, $virtdev_hash) = restore_prepare_new_config(
-            $rpcenv, $user, $vmid, $cfgfn, $storecfg, $devinfo, $opts,
-        );
-
         my $fwcfgfn = "$tmpdir/qemu-server.fw";
         restore_firewall_config($vmid, $fwcfgfn) if -f $fwcfgfn;
 
-- 
2.47.3





      parent reply	other threads:[~2026-11-27 13:47 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 ` [PATCH qemu-server 02/10] restore: skip non-main config sections Fiona Ebner
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 ` Fiona Ebner [this message]

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-11-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal