public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com, Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 1/4] vmstatus: make boolean value explicit
Date: Thu, 4 Mar 2021 09:59:28 +0100	[thread overview]
Message-ID: <334f5cd7-4099-7483-72d8-62cc11e74938@proxmox.com> (raw)
In-Reply-To: <902a59fa-0406-8427-8825-5de95cd9805f@proxmox.com>

Am 04.03.21 um 09:04 schrieb Fabian Ebner:
> Am 03.03.21 um 17:53 schrieb Thomas Lamprecht:
>> On 03.03.21 12:01, Fabian Ebner wrote:
>>> as otherwise the empty string is printed with 'qm status <id> 
>>> --verbose' when
>>> it's not a template.
>>>
>>> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
>>> ---
>>>   PVE/QemuServer.pm | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>>> index a498444..43d7c6b 100644
>>> --- a/PVE/QemuServer.pm
>>> +++ b/PVE/QemuServer.pm
>>> @@ -2621,7 +2621,7 @@ sub vmstatus {
>>>       $d->{diskread} = 0;
>>>       $d->{diskwrite} = 0;
>>> -        $d->{template} = PVE::QemuConfig->is_template($conf);
>>> +        $d->{template} = PVE::QemuConfig->is_template($conf) ? 1 : 0;
>>
>>
>> Any reason to not do:
>>
>> $d->{template} = 1 if PVE::QemuConfig->is_template($conf);
>>
>> (no hard feelings, but this is relatively common pattern for such things,
>> especially if they can be normally more often omitted than not, templates
>> are normally rather outnumbered by non-templates)
>>
> 
> Not really a reason, just that the key was always present before the 
> change too. But it's not an API return key, so making this optional is 
> no problem at all (and we do so for other ones like the 'serial' below, 
> so it's also more consistent in a way). I'll send a v2.
> 

Well, turns out this is a reason. Namely the web UI currently relies on 
the property being there:

     rec = s.data.get('template');
     template = rec.data.value || false;

Should I still go for it?


Also, we say

     lock => {
         description => "The current config lock, if any.",
         type => 'string',
         optional => 1,
     },

but for containers, we do

     $d->{lock} = $conf->{lock} || '';

so it doesn't fully match the description (it's de-facto not optional). 
The reason is that there's a 'lock' column for 'pct list', see 
pve-container commit d02262048cbbe91ca8b12f98e3dc7bbab28e4c64. Is it 
worth changing the description or should the behavior rather be changed 
(while adapting the printing for 'pct list' of course)?

>>>       $d->{serial} = 1 if conf_has_serial($conf);
>>>       $d->{lock} = $conf->{lock} if $conf->{lock};
>>>
>>
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




  reply	other threads:[~2021-03-04  9:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 11:01 [pve-devel] [PATCH-SERIES] small improvements for parsing and printing Fabian Ebner
2021-03-03 11:01 ` [pve-devel] [PATCH qemu-server 1/4] vmstatus: make boolean value explicit Fabian Ebner
2021-03-03 16:53   ` Thomas Lamprecht
2021-03-04  8:04     ` Fabian Ebner
2021-03-04  8:59       ` Fabian Ebner [this message]
2021-03-03 11:01 ` [pve-devel] [PATCH qemu-server 2/4] config: parse: also warn about invalid lines Fabian Ebner
2021-03-03 16:51   ` [pve-devel] applied: " Thomas Lamprecht
2021-03-03 11:01 ` [pve-devel] [PATCH container 3/4] vmstatus: make boolean value explicit Fabian Ebner
2021-03-03 16:53   ` Thomas Lamprecht
2021-03-03 11:01 ` [pve-devel] [PATCH container 4/4] config: parse: also allow empty values Fabian Ebner

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=334f5cd7-4099-7483-72d8-62cc11e74938@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal