[pve-devel] [PATCH pve-zsync 1/2] fix #910: Correctly handle undef

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Mar 9 12:39:54 CET 2016


---
 pve-zsync | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pve-zsync b/pve-zsync
index d517ece..5fecbc2 100644
--- a/pve-zsync
+++ b/pve-zsync
@@ -425,7 +425,7 @@ sub list {
 	    $list .= sprintf("%-25s", cut_target_width($name, 25));
 	    $list .= sprintf("%-10s", $states->{$source}->{$name}->{state});
 	    $list .= sprintf("%-20s", $states->{$source}->{$name}->{lsync});
-	    $list .= sprintf("%-6s", $states->{$source}->{$name}->{vm_type});
+	    $list .= sprintf("%-6s", defined($states->{$source}->{$name}->{vm_type}) ? $states->{$source}->{$name}->{vm_type} : "undef");
 	    $list .= sprintf("%-5s\n", $cfg->{$source}->{$name}->{method});
 	}
     }
@@ -440,6 +440,8 @@ sub vm_exists {
 
     my $res = undef;
 
+    return undef if !defined($target->{vmid});
+
     eval { $res = run_cmd([@cmd, 'ls',  "$QEMU_CONF/$target->{vmid}.conf"]) };
 
     return "qemu" if $res;
-- 
2.1.4





More information about the pve-devel mailing list