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: [pve-devel] [PATCH qemu-server 3/3] vm start: remove left-over VM-state-related properties
Date: Thu, 18 Sep 2025 11:38:42 +0200	[thread overview]
Message-ID: <20250918093842.16059-4-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250918093842.16059-1-f.ebner@proxmox.com>

When cloning from a snapshot, VM-state-related properties would be
accidentally copied, see commit "partially fix #6805: api: clone:
properly remove all snapshot-related info". Detect and remove such
left-over properties upon VM start.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Link: https://lore.proxmox.com/20250917163038.488710-7-f.ebner@proxmox.com
(cherry picked from commit 0db14e60109ea91a558f0f08594583588ef9ec66)
[FE: drop running-nets-host-mtu which does not exist in PVE 8]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 8bc55def..94d12a92 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -5905,6 +5905,20 @@ sub vm_migrate_alloc_nbd_disks {
     return $nbd;
 }
 
+my sub remove_left_over_vmstate_opts {
+    my ($vmid, $conf) = @_;
+
+    my $found;
+    for my $opt (qw(runningmachine runningcpu)) {
+        if (defined($conf->{$opt})) {
+            print "No VM state set, removing left-over option '$opt'\n";
+            delete $conf->{$opt};
+            $found = 1;
+        }
+    }
+    PVE::QemuConfig->write_config($vmid, $conf) if $found;
+}
+
 # see vm_start_nolock for parameters, additionally:
 # migrate_opts:
 #   storagemap = parsed storage map for allocating NBD disks
@@ -6434,6 +6448,8 @@ sub vm_start_nolock {
         }
         delete $conf->@{qw(lock vmstate runningmachine runningcpu)};
         PVE::QemuConfig->write_config($vmid, $conf);
+    } elsif (!$conf->{vmstate}) {
+        remove_left_over_vmstate_opts($vmid, $conf);
     }
 
     PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start');
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


      parent reply	other threads:[~2025-09-18  9:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  9:38 [pve-devel] [PATCH-SERIES qemu-server stable-bookworm 0/3] VM-state property handling improvements Fiona Ebner
2025-09-18  9:38 ` [pve-devel] [PATCH qemu-server 1/3] partially fix #6805: api: clone: properly remove all snapshot-related info Fiona Ebner
2025-09-18  9:38 ` [pve-devel] [PATCH qemu-server 2/3] partially fix #6805: api: modify vm config: privilege checks for VM-state-related properties Fiona Ebner
2025-09-18  9:38 ` 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=20250918093842.16059-4-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