From 275a6f477ce06da1fd4d524b5657d0c99088cf18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 18 Feb 2025 13:56:58 +0100 Subject: [PATCH] config: revamp NoWrite interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Fiona Ebner --- 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; }