[pve-devel] [PATCH v5 03/19] parse_vm_config: only allow 'delete' inside [PENDING]
Dietmar Maurer
dietmar at proxmox.com
Tue Nov 25 10:19:23 CET 2014
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/QemuServer.pm | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index e020740..9b03e6a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1792,22 +1792,24 @@ sub parse_vm_config {
my $conf = $res;
my $descr = '';
+ my $section = '';
my @lines = split(/\n/, $raw);
foreach my $line (@lines) {
next if $line =~ m/^\s*$/;
if ($line =~ m/^\[PENDING\]\s*$/i) {
+ $section = 'pending';
$conf->{description} = $descr if $descr;
$descr = '';
- $conf = $res->{pending} = {};
+ $conf = $res->{$section} = {};
next;
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
- my $snapname = $1;
+ $section = $1;
$conf->{description} = $descr if $descr;
$descr = '';
- $conf = $res->{snapshots}->{$snapname} = {};
+ $conf = $res->{snapshots}->{$section} = {};
next;
}
@@ -1824,9 +1826,8 @@ 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;
+ } elsif (($section eq 'pending') && ($line =~ m/^delete:\s*(.*\S)\s*$/)) {
+ my $value = $1;
foreach my $opt (split(/,/, $value)) {
$conf->{del}->{$opt} = 1;
}
--
1.7.10.4
More information about the pve-devel
mailing list