From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 0B8FB1FF0AE for ; Tue, 01 Sep 2026 16:20:39 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id EF370214DC; Tue, 01 Sep 2026 16:20:36 +0200 (CEST) Message-ID: Date: Tue, 1 Sep 2026 16:20:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: David Riley Subject: Re: [PATCH pve-manager 5/6] ui: qemu: options: add editor for reboot behavior To: Jakob Klocker , pve-devel@lists.proxmox.com References: <20260813112717.272254-1-j.klocker@proxmox.com> <20260813112717.272254-6-j.klocker@proxmox.com> Content-Language: en-US In-Reply-To: <20260813112717.272254-6-j.klocker@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788272428340 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.808 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ID2NTSSYV7OHZHMJ635MVVVIPBG4P55E X-Message-ID-Hash: ID2NTSSYV7OHZHMJ635MVVVIPBG4P55E X-MailFrom: d.riley@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: see comments inline On 8/13/26 1:27 PM, Jakob Klocker wrote: > The `reboot` option is now a property string with an added `powercycle` > sub-property, so expose both in the VM options panel: one checkbox to > allow reboots at all, and one to stop and start the VM on a > guest-initated reboot instead of resetting it in place, which makes > pending changes take effect. > > Signed-off-by: Jakob Klocker > --- > www/manager6/Makefile | 1 + > www/manager6/Utils.js | 17 +++++++ > www/manager6/form/RebootFeatureSelector.js | 59 ++++++++++++++++++++++ > www/manager6/qemu/Options.js | 14 +++++ > 4 files changed, 91 insertions(+) > create mode 100644 www/manager6/form/RebootFeatureSelector.js > > diff --git a/www/manager6/Makefile b/www/manager6/Makefile > index eb0e9d9c..40f71b8c 100644 > --- a/www/manager6/Makefile > +++ b/www/manager6/Makefile > @@ -67,6 +67,7 @@ JSSRC= \ > form/PrivilegesSelector.js \ > form/QemuBiosSelector.js \ > form/QemuMachineSelector.js \ > + form/RebootFeatureSelector.js \ > form/RecordSearchField.js \ > form/SDNControllerSelector.js \ > form/SDNZoneSelector.js \ > diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js > index 040b5ae0..f10c26d5 100644 > --- a/www/manager6/Utils.js > +++ b/www/manager6/Utils.js > @@ -1160,6 +1160,23 @@ Ext.define('PVE.Utils', { > return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s'); > }, > > + render_reboot: function (value) { nit: this should be in camelCase see style guide [0] [0] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Casing > + let normal = gettext('Reboot normally'); > + > + if (value === undefined || value === '') { nit: here you are just catching undefined values but not 'null' values. Consider using 'Ext.isEmpty(value)' here as this would cover 'null', 'undefined' as well as the empty string check, see [1]. [1] https://docs.sencha.com/extjs/7.0.0/classic/Ext.html#method-isEmpty > + return `${Proxmox.Utils.defaultText} (${normal})`; > + } > + > + let props = PVE.Parser.parsePropertyString(value, 'enabled'); > + if (!PVE.Parser.parseBoolean(props.enabled, 1)) { > + return gettext('Shut down instead of rebooting'); > + } > + if (PVE.Parser.parseBoolean(props.powercycle, 0)) { > + return gettext('Stop and start the VM on guest reboot'); > + } > + return normal; > + }, > + > // render a timestamp or pending > render_next_event: function (value) { > if (!value) { > diff --git a/www/manager6/form/RebootFeatureSelector.js b/www/manager6/form/RebootFeatureSelector.js > new file mode 100644 > index 00000000..88e93da3 > --- /dev/null > +++ b/www/manager6/form/RebootFeatureSelector.js > @@ -0,0 +1,59 @@ > +Ext.define('PVE.form.RebootFeatureSelector', { > + extend: 'Proxmox.panel.InputPanel', > + alias: ['widget.pveRebootFeatureSelector'], > + > + viewModel: {}, > + > + items: [ > + { > + xtype: 'proxmoxcheckbox', > + boxLabel: gettext('Allow reboot'), > + name: 'enabled', > + reference: 'enabled', > + uncheckedValue: 0, > + }, > + { > + xtype: 'proxmoxcheckbox', > + boxLabel: gettext('Stop and start the VM on guest reboot (applies pending changes)'), > + name: 'powercycle', > + uncheckedValue: 0, > + bind: { > + disabled: '{!enabled.checked}', > + }, > + disabled: true, > + }, > + { > + xtype: 'displayfield', > + userCls: 'pmx-hint', > + value: gettext('The VM is shut down instead of rebooted and stays off.'), > + bind: { > + hidden: '{enabled.checked}', > + }, > + }, > + ], > + > + onGetValues: function (values) { > + let enabled = !Ext.isDefined(values.enabled) || String(values.enabled) === '1'; Do we need the !Ext.isDefined check here? Is it not guaranteed that this will always hold a value, because you have set 'uncheckedValue: 0' on the proxmoxcheckbox? > + let powercycle = String(values.powercycle) === '1'; > + > + // equivalent to the default, so don't write the option at all > + if (enabled && !powercycle) { > + return { delete: 'reboot' }; > + } > + > + let props = { enabled: enabled ? 1 : 0 }; > + if (powercycle) { > + props.powercycle = 1; > + } > + > + return { reboot: PVE.Parser.printPropertyString(props, 'enabled') }; > + }, > + > + setValues: function (values) { > + let res = PVE.Parser.parsePropertyString(values.reboot, 'enabled'); > + if (!Ext.isDefined(res.enabled)) { > + res.enabled = 1; > + } > + this.callParent([res]); > + }, > +}); > diff --git a/www/manager6/qemu/Options.js b/www/manager6/qemu/Options.js > index 8a4721a0..4fd5d1bb 100644 > --- a/www/manager6/qemu/Options.js > +++ b/www/manager6/qemu/Options.js > @@ -84,6 +84,20 @@ Ext.define('PVE.qemu.Options', { > } > : undefined, > }, > + reboot: { > + header: gettext('Reboot behavior'), > + defaultValue: '', > + renderer: PVE.Utils.render_reboot, > + editor: caps.vms['VM.Config.Options'] > + ? { > + xtype: 'proxmoxWindowEdit', > + subject: gettext('Reboot behavior'), > + onlineHelp: 'qm_reboot_behavior', > + width: 350, > + items: { xtype: 'pveRebootFeatureSelector', name: 'reboot' }, nit: is the name here actually needed? > + } > + : undefined, > + }, > ostype: { > header: gettext('OS Type'), > editor: caps.vms['VM.Config.Options']