we did not check if some values were hash refs in the verbose output. this patch adds a recursive hash print sub and uses it
Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> --- PVE/CLI/qm.pm | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index d0d7a6c..e513f33 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -75,6 +75,32 @@ sub run_vnc_proxy { exit(0); } +sub print_recursive_hash { + my ($prefix, $hash, $key) = @_; + + if (ref($hash) eq 'HASH') { + if (defined($key)) { + print "$prefix$key:\n"; + } + foreach my $itemkey (keys %$hash) { + print_recursive_hash("\t$prefix", $hash->{$itemkey}, $itemkey); + } + } elsif (ref($hash) eq 'ARRAY') { + if (defined($key)) { + print "$prefix$key:\n"; + } + foreach my $item (@$hash) { + print_recursive_hash("\t$prefix", $item); + } + } elsif (!ref($hash) && defined($hash)) { + if (defined($key)) { + print "$prefix$key: $hash\n"; + } else { + print "$prefix$hash\n"; + } + } +} + __PACKAGE__->register_method ({ name => 'showcmd', path => 'showcmd', @@ -125,8 +151,7 @@ __PACKAGE__->register_method ({ foreach my $k (sort (keys %$stat)) { next if $k eq 'cpu' || $k eq 'relcpu'; # always 0 my $v = $stat->{$k}; - next if !defined($v); - print "$k: $v\n"; + print_recursive_hash("", $v, $k); } } else { my $status = $stat->{qmpstatus} || 'unknown'; -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel