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

2015-09-10 Thread Dietmar Maurer
> +if (($conf->{protection}) && ($conf->{protection} == 1)) > { What is the purpose of this strict test? I thought the following is good enough: if ($conf->{protection}) { ... ___ pve-devel mailing list pve-devel@pve.proxmox.com

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

2015-09-10 Thread Dietmar Maurer
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"; > +

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

2015-09-10 Thread Alen Grizonic
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

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

2015-09-10 Thread Alen Grizonic
v5 changes: - disk removal prevention -> added unused disk removal prevention - protection option removal prevention - changed man page message --- PVE/API2/Qemu.pm | 8 PVE/QemuServer.pm | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Qemu.pm

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

2015-09-10 Thread Alen Grizonic
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

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

2015-09-10 Thread Dietmar Maurer
> > +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

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

2015-09-10 Thread Alen Grizonic
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

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

2015-09-10 Thread Dietmar Maurer
> The thing is that the checks are always repeated, but the error messages > are different. I can't see any strict need for those different error messages. Instead, a common error message makes more sense to me, because the reason is always the same.