[pve-devel] [RFC v5 qemu-server] VM protection mode

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 10 17:04:48 CEST 2015


Dietmar, sorry for the delayed reply. Yes, we can use just

if ($conf->{protection}) { ...


On 09/10/2015 04:59 PM, Dietmar Maurer wrote:
>>> +                    if (($conf->{protection}) && ($conf->{protection} ==
>>> 1))
>>> {
>> What is the purpose of this strict test? I thought the following is good
>> enough:
>>
>> if ($conf->{protection}) { ...
> I will try to explain more elaborate.
>
> We use type 'boolean' for the 'protection' property, and we use
> the following code in PVE::QemuServer::check_type()
>
>      if ($type eq 'boolean') {
> 	return 1 if ($value eq '1') || ($value =~ m/^(on|yes|true)$/i);
> 	return 0 if ($value eq '0') || ($value =~ m/^(off|no|false)$/i);
> 	die "type check ('boolean') failed - got '$value'\n";
> ...
>
>
> this makes sure we get either 0 or 1.
>
> We have similar code in PVE::LXC::check_type().





More information about the pve-devel mailing list