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

Dietmar Maurer dietmar at proxmox.com
Thu Sep 10 17:19:51 CEST 2015


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