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

Dietmar Maurer dietmar at proxmox.com
Thu Sep 10 16:59:28 CEST 2015


> > +                    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