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 [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 7E3361FF189 for <inbox@lore.proxmox.com>; Fri, 4 Apr 2025 14:54:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7EE631F775; Fri, 4 Apr 2025 14:54:20 +0200 (CEST) From: Dominik Csapak <d.csapak@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 4 Apr 2025 14:53:41 +0200 Message-Id: <20250404125345.3244659-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250404125345.3244659-1-d.csapak@proxmox.com> References: <20250404125345.3244659-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v3 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> So users can disable them (they're enabled by default in QEMU) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com> --- changes from v2: * different name for function * removed comment intended for next patch * don't put function call inside 'if ()' PVE/QemuServer.pm | 2 ++ PVE/QemuServer/Machine.pm | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 366c83b9..5c0f4476 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4011,6 +4011,8 @@ sub config_to_command { if (!$kvm) { push @$machineFlags, 'accel=tcg'; } + my $power_state_flags = PVE::QemuServer::Machine::get_power_state_flags($machine_conf); + push $cmd->@*, $power_state_flags->@* if defined($power_state_flags); push @$machineFlags, 'smm=off' if should_disable_smm($conf, $vga, $machine_type); diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm index a5962443..39e7b5b4 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,30 @@ sub check_and_pin_machine_string { return print_machine($machine_conf); } +# returns an arrayref of cmdline options for qemu or undef +sub 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; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel