using following variant to improve readability:

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index e15c0c3..18fb8fd 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2751,10 +2751,10 @@ __PACKAGE__->register_method({
 
        if ($target && ($target eq $localnode || $target eq 'localhost')) {
            undef $target;
-       } else {
-           PVE::Cluster::check_node_exists($target);
        }
 
+       PVE::Cluster::check_node_exists($target) if $target;
+
        my $storecfg = PVE::Storage::config();
 
        if ($storage) {

On February 3, 2020 4:23 pm, Oguz Bektas wrote:
> regression introduced with commit a85ff91b
> 
> previously we set $target to undef if it's localnode or localhost, then
> we check if node exists.
> 
> with regression commit, behaviour changes as we do the node check in
> else, but $target may be undef. this causes an error:
> 
>     no such cluster node ''
> 
> Signed-off-by: Oguz Bektas <o.bek...@proxmox.com>
> ---
>  PVE/API2/Qemu.pm | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index e15c0c3..fe68e87 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -2749,10 +2749,12 @@ __PACKAGE__->register_method({
>  
>          my $localnode = PVE::INotify::nodename();
>  
> -        if ($target && ($target eq $localnode || $target eq 'localhost')) {
> -         undef $target;
> -     } else {
> -         PVE::Cluster::check_node_exists($target);
> +     if ($target) {
> +         if ($target eq $localnode || $target eq 'localhost') {
> +             undef $target;
> +         } else {
> +             PVE::Cluster::check_node_exists($target);
> +         }
>       }
>  
>       my $storecfg = PVE::Storage::config();
> -- 
> 2.20.1
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to