From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 715F91FF189 for <inbox@lore.proxmox.com>; Fri, 4 Apr 2025 13:53:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8FFC61D5DA; Fri, 4 Apr 2025 13:53:07 +0200 (CEST) Message-ID: <0c2f9b7a-26b5-4961-853c-053d5a1c9cc4@proxmox.com> Date: Fri, 4 Apr 2025 13:53:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>, Dominik Csapak <d.csapak@proxmox.com> References: <20250307144436.122621-1-d.csapak@proxmox.com> <20250307144436.122621-6-d.csapak@proxmox.com> Content-Language: en-US From: Fiona Ebner <f.ebner@proxmox.com> In-Reply-To: <20250307144436.122621-6-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.037 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm, machine.pm] Subject: Re: [pve-devel] [PATCH qemu-server v2 5/8] machine: add S3/S4 power state properties X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Am 07.03.25 um 15:44 schrieb Dominik Csapak: > So users can disable them (they're enabled by default in QEMU) > > Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> > --- > changes from v1: > * rework the method with suggestions from fiona > * change way we add flags because we don't have globalflags anymore > > PVE/QemuServer.pm | 4 ++++ > PVE/QemuServer/Machine.pm | 37 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index 1da7e9a1..1aaee8d0 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -3975,6 +3975,10 @@ sub config_to_command { > push @$machineFlags, 'accel=tcg'; > } > > + if (my $options = PVE::QemuServer::Machine::check_and_set_power_state_flags($machine_conf)) { > + push $cmd->@*, $options->@*; > + } Nit: I think $options is too generic of a variable name. I'd rather have the function call not inside the if and a nicer name like $power_state_flags. Then you can check the variable in the if (or post-if ;)) > + > push @$machineFlags, 'smm=off' if should_disable_smm($conf, $vga, $machine_type); > > my $machine_type_min = $machine_type; > diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm > index a5962443..d2349d4d 100644 > --- a/PVE/QemuServer/Machine.pm > +++ b/PVE/QemuServer/Machine.pm > @@ -31,6 +31,16 @@ my $machine_fmt = { > enum => ['intel', 'virtio'], > optional => 1, > }, > + 'enable-s3' => { > + type => 'boolean', > + description => "Enables S3 power state. Defaults to true.", > + optional => 1, > + }, > + 'enable-s4' => { > + type => 'boolean', > + description => "Enables S4 power state. Defaults to true.", > + optional => 1, > + }, > }; > > PVE::JSONSchema::register_format('pve-qemu-machine-fmt', $machine_fmt); > @@ -284,4 +294,31 @@ sub check_and_pin_machine_string { > return print_machine($machine_conf); > } > > +# disable s3/s4 by default for 9.2+pve1 machine types Nit: this comment line belongs to the next patch. > +# returns a list of cmdline options for qemu or undef Nit: actually an array ref, not a list. > +sub check_and_set_power_state_flags { Should be renamed as it doesn't set anything. Maybe "get_power_state_flags"? > + my ($machine_conf) = @_; > + > + my $object = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? "ICH9-LPC" : "PIIX4_PM"; > + > + my $s3 = $machine_conf->{'enable-s3'} // 1; > + my $s4 = $machine_conf->{'enable-s4'} // 1; > + > + my $options = []; > + > + # they're enabled by default in QEMU, so only add the flags to disable them > + if (!$s3) { > + push $options->@*, '-global', "${object}.disable_s3=1"; > + } > + if (!$s4) { > + push $options->@*, '-global', "${object}.disable_s4=1"; > + } > + > + if (scalar($options->@*)) { > + return $options; > + } > + > + return; > +} > + > 1; _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel