mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-04-28 15:47:21 +00:00
parse config: warn about duplicate sections
Currently, a duplicate section will quietly override the previous instance of the section with the same identifier. Keep the current behavior of preferring later entries, but issue a warning or die when parsing strictly. The entry for 'pending' in the result needs to start out as undefined for the check to also work in presence of empty sections. Avoid changing the returned value itself, by making sure to initialize the entry before returning. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Link: https://lore.proxmox.com/20250127112923.31703-12-f.ebner@proxmox.com
This commit is contained in:
parent
90ae915305
commit
68eabc42c1
@ -2202,7 +2202,7 @@ sub parse_vm_config {
|
||||
my $res = {
|
||||
digest => Digest::SHA::sha1_hex($raw),
|
||||
snapshots => {},
|
||||
pending => {},
|
||||
pending => undef,
|
||||
'special-sections' => {},
|
||||
};
|
||||
|
||||
@ -2242,17 +2242,23 @@ sub parse_vm_config {
|
||||
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
||||
$section = { name => 'pending', type => 'pending' };
|
||||
$finish_description->();
|
||||
$handle_error->("vm $vmid - duplicate section: $section->{name}\n")
|
||||
if defined($res->{$section->{name}});
|
||||
$conf = $res->{$section->{name}} = {};
|
||||
next;
|
||||
} elsif ($line =~ m/^\[special:$special_sections_re_1\]\s*$/i) {
|
||||
$section = { name => $1, type => 'special' };
|
||||
$finish_description->();
|
||||
$handle_error->("vm $vmid - duplicate special section: $section->{name}\n")
|
||||
if defined($res->{'special-sections'}->{$section->{name}});
|
||||
$conf = $res->{'special-sections'}->{$section->{name}} = {};
|
||||
next;
|
||||
|
||||
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
|
||||
$section = { name => $1, type => 'snapshot' };
|
||||
$finish_description->();
|
||||
$handle_error->("vm $vmid - duplicate snapshot section: $section->{name}\n")
|
||||
if defined($res->{snapshots}->{$section->{name}});
|
||||
$conf = $res->{snapshots}->{$section->{name}} = {};
|
||||
next;
|
||||
} elsif ($line =~ m/^\[([^\]]*)\]\s*$/i) {
|
||||
@ -2322,6 +2328,8 @@ sub parse_vm_config {
|
||||
$finish_description->();
|
||||
delete $res->{snapstate}; # just to be sure
|
||||
|
||||
$res->{pending} = {} if !defined($res->{pending});
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
vm 8006 - duplicate section: pending
|
Loading…
Reference in New Issue
Block a user