From: Jakob Klocker <j.klocker@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Jakob Klocker <j.klocker@proxmox.com>
Subject: [PATCH qemu-server 2/6] fix #7213: config: add `powercycle` sub-property to `reboot`
Date: Thu, 13 Aug 2026 13:27:13 +0200 [thread overview]
Message-ID: <20260813112717.272254-3-j.klocker@proxmox.com> (raw)
In-Reply-To: <20260813112717.272254-1-j.klocker@proxmox.com>
A guest-initiated reboot is handled by QEMU itself, so the process keeps
running and the VM stays on the configuration and QEMU binary it was
started with. Pending changes therefore remain pending.
With `powercycle` set, start the VM with `-no-reboot` so that QEMU exits
on a reset instead. `qm cleanup` then starts the VM again, which makes
it a full start and applies pending changes. Note that `-no-reboot`
covers resets requested through the API as well, so those also become a
full stop and start.
Convert `reboot` to a property string to carry the new sub-property.
Existing configurations stay valid, as the previous boolean value is the
default key.
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7213
Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
src/PVE/QemuServer.pm | 41 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 2f43faa7..1727f143 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -237,6 +237,27 @@ my $spice_enhancements_fmt = {
},
};
+my $reboot_fmt = {
+ enabled => {
+ default_key => 1,
+ type => 'boolean',
+ default => 1,
+ optional => 1,
+ description => "Allow reboot. If set to '0' the VM is shut down instead of rebooted"
+ . " and stays off, no matter whether the reboot was initiated by the guest or"
+ . " through the API.",
+ },
+ powercycle => {
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ description => "Stop and start the VM on a reset instead of resetting it in place, so"
+ . " pending changes are applied and the currently installed QEMU version is used."
+ . " Applies to resets initiated by the guest as well as through the API. Has no"
+ . " effect when reboot is disabled.",
+ },
+};
+
my $confdesc = {
onboot => {
optional => 1,
@@ -263,9 +284,9 @@ my $confdesc = {
},
reboot => {
optional => 1,
- type => 'boolean',
- description => "Allow reboot. If set to '0' the VM exit on reboot.",
- default => 1,
+ type => 'string',
+ format => $reboot_fmt,
+ description => "Reboot behavior and its properties.",
},
lock => {
optional => 1,
@@ -1694,6 +1715,16 @@ sub parse_vga {
return $res;
}
+sub parse_reboot {
+ my ($value) = @_;
+
+ return { enabled => 1 } if !defined($value) || $value eq '';
+
+ my $res = eval { parse_property_string($reboot_fmt, $value) };
+ warn $@ if $@;
+ return $res // {};
+}
+
sub qemu_created_version_fixups {
my ($conf, $forcemachine, $kvmver) = @_;
@@ -3216,6 +3247,8 @@ sub config_to_command {
push @$cmd, '-name', "$vmname,debug-threads=on";
}
+ my $reboot = parse_reboot($conf->{reboot});
+ push @$cmd, '-no-reboot' if !($reboot->{enabled} // 1) || $reboot->{powercycle};
push @$cmd, '-no-shutdown';
my $use_virtio = 0;
@@ -3400,8 +3433,6 @@ sub config_to_command {
push $machineFlags->@*, 'acpi=off' if defined($conf->{acpi}) && $conf->{acpi} == 0;
- push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0;
-
if ($vga->{type} && $vga->{type} !~ m/^serial\d+$/ && $vga->{type} ne 'none') {
push @$devices, '-device',
print_vga_device($conf, $vga, $arch, $machine_version, undef, $qxlnum, $bridges);
--
2.47.3
next prev parent reply other threads:[~2026-08-13 11:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 11:27 [PATCH docs/manager/qemu-server 0/6] fix #7213: add `powercycle` reboot behavior Jakob Klocker
2026-08-13 11:27 ` [PATCH qemu-server 1/6] qm: do not restart VM when 'reboot' is disabled Jakob Klocker
2026-08-13 11:27 ` Jakob Klocker [this message]
2026-08-13 11:27 ` [PATCH qemu-server 3/6] fix #7213: qm: cleanup: add `reset` parameter to honor `powercycle` Jakob Klocker
2026-08-13 11:27 ` [PATCH qemu-server 4/6] fix #7213: qmeventd: pass `reset` to `qm cleanup` Jakob Klocker
2026-08-13 11:27 ` [PATCH pve-manager 5/6] ui: qemu: options: add editor for reboot behavior Jakob Klocker
2026-08-13 11:27 ` [PATCH pve-docs 6/6] qm: add reboot behavior information Jakob Klocker
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=20260813112717.272254-3-j.klocker@proxmox.com \
--to=j.klocker@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.