[pve-devel] [PATCH qemu-server 1/2] config: revamp NoWrite interface

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Feb 18 14:08:11 CET 2025


instead of blessing a passed-in config and returning it, explicitly only bless
without returning to make it more obvious to callers that this affects the
argument.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/QemuConfig/NoWrite.pm | 4 +---
 PVE/QemuServer.pm         | 4 +++-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuConfig/NoWrite.pm b/PVE/QemuConfig/NoWrite.pm
index f697506f..02e5f158 100644
--- a/PVE/QemuConfig/NoWrite.pm
+++ b/PVE/QemuConfig/NoWrite.pm
@@ -7,12 +7,10 @@ use PVE::RESTEnvironment qw(log_warn);
 
 use base qw(PVE::QemuConfig);
 
-sub new {
+sub mark_config {
     my ($class, $conf) = @_;
 
     bless($conf, $class);
-
-    return $conf;
 }
 
 sub write_config {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b23b79e1..9d06ac8b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3398,7 +3398,6 @@ sub config_to_command {
 	    bios => $conf->{bios}, # so efidisk gets included if it exists
 	    name => $conf->{name}, # so it's correct in the process list
 	};
-	$newconf = PVE::QemuConfig::NoWrite->new($newconf);
 
 	# copy all disks over
 	for my $device (PVE::QemuServer::Drive::valid_drive_names()) {
@@ -3407,6 +3406,9 @@ sub config_to_command {
 
 	# remaining configs stay default
 
+	# mark config to prevent writing it out
+	PVE::QemuConfig::NoWrite->mark_config($newconf);
+
 	$conf = $newconf;
     }
 
-- 
2.39.5





More information about the pve-devel mailing list