[pve-devel] [PATCH v3 guest-common 03/19] helpers: add pending-aware guest config printer from qemu-server

Oguz Bektas o.bektas at proxmox.com
Mon Oct 14 10:28:35 CEST 2019


Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 PVE/GuestHelpers.pm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/PVE/GuestHelpers.pm b/PVE/GuestHelpers.pm
index 35059e6..a36b9bc 100644
--- a/PVE/GuestHelpers.pm
+++ b/PVE/GuestHelpers.pm
@@ -116,4 +116,30 @@ sub print_snapshot_tree {
     }
 }
 
+sub format_pending {
+    my ($data) = @_;
+    foreach my $item (sort { $a->{key} cmp $b->{key}} @$data) {
+	my $k = $item->{key};
+	next if $k eq 'digest';
+	my $v = $item->{value};
+	my $p = $item->{pending};
+	if ($k eq 'description') {
+	    $v = PVE::Tools::encode_text($v) if defined($v);
+	    $p = PVE::Tools::encode_text($p) if defined($p);
+	}
+	if (defined($v)) {
+	    if ($item->{delete}) {
+		print "del $k: $v\n";
+	    } elsif (defined($p)) {
+		print "cur $k: $v\n";
+		print "new $k: $p\n";
+	    } else {
+		print "cur $k: $v\n";
+	    }
+	} elsif (defined($p)) {
+	    print "new $k: $p\n";
+	}
+    }
+}
+
 1;
-- 
2.20.1




More information about the pve-devel mailing list