mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-01 06:15:25 +00:00
config: add S3/S4 power state properties to machine option
So users can disable them, as they're enabled by default in QEMU. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com> Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com> Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com> Link: https://lore.proxmox.com/20250404125345.3244659-6-d.csapak@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
1d4da507b3
commit
80ddee39a5
@ -3965,6 +3965,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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user