all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 6/8] machine: add S3/S4 power state properties
Date: Fri, 7 Mar 2025 11:02:01 +0100	[thread overview]
Message-ID: <c2ccb252-32c3-4a15-af30-bb99e4dca2ac@proxmox.com> (raw)
In-Reply-To: <ad1703a0-ec57-4784-a87d-fddda4226cf2@proxmox.com>

On 3/6/25 15:52, Fiona Ebner wrote:
> Am 06.03.25 um 11: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>
>> ---
>> This patch may make sense, regardless if we'll apply the reversal of the
>> default...
>>
>>   PVE/QemuServer.pm         |  2 ++
>>   PVE/QemuServer/Machine.pm | 40 +++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 42 insertions(+)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index 13af495d..b8ce4750 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -3975,6 +3975,8 @@ sub config_to_command {
>>   	push @$machineFlags, 'accel=tcg';
>>       }
>>   
>> +    PVE::QemuServer::Machine::check_and_set_power_state_flags($globalFlags, $machine_conf);
>> +
>>       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 ebaf2dcc..377abc8a 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);
> 
> Note that an UI patch is needed, because editing the machine there will
> not preserve these values currently.
> 

alternative suggestions: I'd prefer to return the +pveX machines (where X > 0)
also in the 'capabilities/qemu/machine' api call listing. This would
1. allow the users of the api to see that there are variants
2. allows the UI to work automagically (since it uses that api call)
    - shows the correct version without losing info
    - makes it possible to select e.g. a +pve1 variant

what do you say?

>> @@ -293,4 +303,34 @@ sub check_and_pin_machine_string {
>>       return print_machine($machine_conf);
>>   }
>>   
>> +# disable s3/s4 by default for 9.2+pve1 machine types
>> +sub check_and_set_power_state_flags {
>> +    my ($globalFlags, $machine_conf) = @_;
>> +
>> +    my $get_flag = sub {
>> +	my ($q35, $type, $value) = @_;
> 
> Style nit: $value is always 1
> 
>> +
>> +	if ($q35) {
>> +	    return "ICH9-LPC.disable_${type}=${value}";
>> +	} else {
>> +	    return "PIIX4_PM.disable_${type}=${value}";
>> +	}
>> +    };
> 
> Rather than this closure, could just be $object = $q35 ? 'ICH9-LPC' :
> 'PIIX4_PM' and then use that for constructing the string when pusing.

ok makes sense, in an early version the code was structured differently
where this closure made more sense, and i didn't clean it up...

> 
>> +
>> +    my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
>> +
>> +    my $s3 = $machine_conf->{'enable-s3'} // 1;
>> +    my $s4 = $machine_conf->{'enable-s4'} // 1;
>> +
>> +    # they're enabled by default in QEMU, so only add the flags to disable them
>> +    if (!$s3) {
>> +	push $globalFlags->@*, $get_flag->($q35, 's3', 1)
> 
> Style nit: missing semicolon
> 
>> +    }
>> +    if (!$s4) {
>> +	push $globalFlags->@*, $get_flag->($q35, 's4', 1)
> 
> Style nit: missing semicolon
> 
>> +    }
>> +
>> +    return;
>> +}
>> +
>>   1;
> 



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


  reply	other threads:[~2025-03-07 10:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 10:44 [pve-devel] [PATCH qemu-server 0/8] disable S3/S4 power states by default Dominik Csapak
2025-03-06 10:44 ` [pve-devel] [RFC PATCH qemu-server 1/8] tests: cfg2cmd: pin QEMU version Dominik Csapak
2025-03-06 12:00   ` Fiona Ebner
2025-03-06 12:07     ` Dominik Csapak
2025-03-06 12:43       ` Fiona Ebner
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 2/8] config to command: add one '-global' option for each flag Dominik Csapak
2025-03-06 12:13   ` Fiona Ebner
2025-03-06 12:15     ` Dominik Csapak
2025-03-06 12:55       ` Fiona Ebner
2025-03-07  9:54         ` Dominik Csapak
2025-03-07 10:00           ` Fiona Ebner
2025-03-07 10:05             ` Dominik Csapak
2025-03-07 10:14               ` Fiona Ebner
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 3/8] meta info: also add current pve-machine version Dominik Csapak
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 4/8] machine: correctly select pve machine version for non pinned windows guests Dominik Csapak
2025-03-06 13:10   ` Fiona Ebner
2025-03-06 13:36     ` Dominik Csapak
2025-03-06 14:10       ` Fiona Ebner
2025-03-06 14:14         ` Fiona Ebner
2025-03-06 14:15         ` Dominik Csapak
2025-03-06 14:20           ` Fiona Ebner
2025-03-07  9:55             ` Dominik Csapak
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 5/8] machine: incorporate pve machine version when pinning " Dominik Csapak
2025-03-06 14:32   ` Fiona Ebner
2025-03-07  9:58     ` Dominik Csapak
2025-03-07 10:06       ` Fiona Ebner
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 6/8] machine: add S3/S4 power state properties Dominik Csapak
2025-03-06 14:52   ` Fiona Ebner
2025-03-07 10:02     ` Dominik Csapak [this message]
2025-03-07 10:10       ` Fiona Ebner
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 7/8] machine: bump pve machine version and reverse the s3/s4 defaults Dominik Csapak
2025-03-06 15:04   ` Fiona Ebner
2025-03-06 10:44 ` [pve-devel] [PATCH qemu-server 8/8] tests: cfg2cmd: add test for windows machine pinning from meta info Dominik Csapak
2025-03-06 15:10   ` Fiona Ebner
2025-03-07 14:46 ` [pve-devel] [PATCH qemu-server 0/8] disable S3/S4 power states by default Dominik Csapak

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=c2ccb252-32c3-4a15-af30-bb99e4dca2ac@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=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