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

Alen Grizonic a.grizonic at proxmox.com
Thu Sep 10 17:29:46 CEST 2015


The thing is that the checks are always repeated, but the error messages 
are different.

I can still add a new common subroutine. Now it actually make sense.


On 09/10/2015 05:24 PM, Alen Grizonic wrote:
> 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?
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>





More information about the pve-devel mailing list