[pve-devel] [PATCH v3 1/9] parse_vm_config : parse pending changes

Dietmar Maurer dietmar at proxmox.com
Mon Nov 17 10:47:17 CET 2014


From: Alexandre Derumier <aderumier at odiso.com>

example:

[PENDING]
virtio1:...
delete:net0,net1

$conf->{pending}->{virtio1}
$conf->{pending}->{del}->{net0}
$conf->{pending}->{del}->{net1}

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/QemuServer.pm |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 02bf404..0241dc0 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1782,6 +1782,7 @@ sub parse_vm_config {
     my $res = {
 	digest => Digest::SHA::sha1_hex($raw),
 	snapshots => {},
+	pending => {}
     };
 
     $filename =~ m|/qemu-server/(\d+)\.conf$|
@@ -1796,7 +1797,11 @@ sub parse_vm_config {
     foreach my $line (@lines) {
 	next if $line =~ m/^\s*$/;
 
-	if ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
+	if ($line =~ m/^\[PENDING\]\s*$/i) {
+	    $conf = $res->{pending} = {};
+	    next;
+
+	}elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
 	    my $snapname = $1;
 	    $conf->{description} = $descr if $descr;
 	    $descr = '';
@@ -1817,6 +1822,12 @@ sub parse_vm_config {
 	    my $key = $1;
 	    my $value = $2;
 	    $conf->{$key} = $value;
+	} elsif ($line =~ m/^(delete):\s*(.*\S)\s*$/) {
+	    my $key = $1;
+	    my $value = $2;
+	    foreach my $opt (split(/,/, $value)) {
+		$conf->{del}->{$opt} = 1;
+	    }
 	} elsif ($line =~ m/^([a-z][a-z_]*\d*):\s*(\S+)\s*$/) {
 	    my $key = $1;
 	    my $value = $2;
-- 
1.7.10.4




More information about the pve-devel mailing list