[pve-devel] [PATCH qemu-server 1/2] parser/writer: namespace pending section

Oguz Bektas o.bektas at proxmox.com
Tue Oct 22 12:12:34 CEST 2019


to make the pct/qemu config formats more similar, we can namespace the
pending section using the 'pve:' prefix like in pct parser.

the new format is optional in the parser, but default in the writer.

with PVE 7.0, we can make it default in parser too.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 PVE/QemuServer.pm | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7b225da..694e1f4 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2643,7 +2643,8 @@ sub parse_vm_config {
     foreach my $line (@lines) {
 	next if $line =~ m/^\s*$/;
 
-	if ($line =~ m/^\[PENDING\]\s*$/i) {
+	if ($line =~ m/^\[(?:pve:)?pending\]\s*$/i) {
+	    # TODO: make 'pve:' prefix non-optional with PVE 7.0
 	    $section = 'pending';
 	    if (defined($descr)) {
 		$descr =~ s/\s+$//;
@@ -2684,7 +2685,7 @@ sub parse_vm_config {
 	    if ($section eq 'pending') {
 		$conf->{delete} = $value; # we parse this later
 	    } else {
-		warn "vm $vmid - propertry 'delete' is only allowed in [PENDING]\n";
+		warn "vm $vmid - property 'delete' is only allowed in [pve:pending]\n";
 	    }
 	} elsif ($line =~ m/^([a-z][a-z_]*\d*):\s*(.+?)\s*$/) {
 	    my $key = $1;
@@ -2750,7 +2751,7 @@ sub write_vm_config {
 		$key eq 'snapstate' || $key eq 'pending';
 	    my $value = $cref->{$key};
 	    if ($key eq 'delete') {
-		die "propertry 'delete' is only allowed in [PENDING]\n"
+		die "property 'delete' is only allowed in [pve:pending]\n"
 		    if !$pending;
 		# fixme: check syntax?
 		next;
@@ -2810,7 +2811,7 @@ sub write_vm_config {
     my $raw = &$generate_raw_config($conf);
 
     if (scalar(keys %{$conf->{pending}})){
-	$raw .= "\n[PENDING]\n";
+	$raw .= "\n[pve:pending]\n";
 	$raw .= &$generate_raw_config($conf->{pending}, 1);
     }
 
@@ -4820,7 +4821,7 @@ my $fast_plug_option = {
     'hookscript' => 1,
 };
 
-# hotplug changes in [PENDING]
+# hotplug changes in [pve:pending]
 # $selection hash can be used to only apply specified options, for
 # example: { cores => 1 } (only apply changed 'cores')
 # $errors ref is used to return error messages
-- 
2.20.1




More information about the pve-devel mailing list