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

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 10 17:24:33 CEST 2015


Agree. I also like non duplicated code, so I'll fix it and add an 
additional restriction right away.

Thanks.

On 09/10/2015 05:19 PM, Dietmar Maurer wrote:
> The code is still clumsy - to show what I mean I just left the
> '+' lines and removed everything else.
>
>
>> +                    if (($conf->{protection}) && ($conf->{protection} == 1))
>> {
>> +                        die "can't remove VM $vmid storage - protection mode
>> enabled\n";
>> +                    }
> ...
>> +		    if (($conf->{protection}) && ($conf->{protection} == 1)) {
>> +			die "can't remove VM $vmid storage - protection mode enabled\n";
>> +		    }
> ..
>> +		} elsif (($conf->{protection}) && ($conf->{protection} == 1)) {
>> +		    die "can't delete VM $vmid protection option - protection mode
>> enabled\n";
> Can you see the code duplication? It is worth to factor out such code and use
> a common subroutine instead. I am sure you can find a common error message?





More information about the pve-devel mailing list