mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-28 11:01:13 +00:00
parse config: factor out finishing reading the description comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
05eae0f21f
commit
cbfc9d753f
@ -2425,6 +2425,13 @@ sub parse_vm_config {
|
||||
|
||||
my $conf = $res;
|
||||
my $descr;
|
||||
my $finish_description = sub {
|
||||
if (defined($descr)) {
|
||||
$descr =~ s/\s+$//;
|
||||
$conf->{description} = $descr;
|
||||
}
|
||||
$descr = undef;
|
||||
};
|
||||
my $section = '';
|
||||
|
||||
my @lines = split(/\n/, $raw);
|
||||
@ -2433,11 +2440,7 @@ sub parse_vm_config {
|
||||
|
||||
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
||||
$section = 'pending';
|
||||
if (defined($descr)) {
|
||||
$descr =~ s/\s+$//;
|
||||
$conf->{description} = $descr;
|
||||
}
|
||||
$descr = undef;
|
||||
$finish_description->();
|
||||
$conf = $res->{$section} = {};
|
||||
next;
|
||||
} elsif ($line =~ m/^\[special:cloudinit\]\s*$/i) {
|
||||
@ -2448,11 +2451,7 @@ sub parse_vm_config {
|
||||
|
||||
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
|
||||
$section = $1;
|
||||
if (defined($descr)) {
|
||||
$descr =~ s/\s+$//;
|
||||
$conf->{description} = $descr;
|
||||
}
|
||||
$descr = undef;
|
||||
$finish_description->();
|
||||
$conf = $res->{snapshots}->{$section} = {};
|
||||
next;
|
||||
}
|
||||
@ -2506,10 +2505,7 @@ sub parse_vm_config {
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($descr)) {
|
||||
$descr =~ s/\s+$//;
|
||||
$conf->{description} = $descr;
|
||||
}
|
||||
$finish_description->();
|
||||
delete $res->{snapstate}; # just to be sure
|
||||
|
||||
return $res;
|
||||
|
Loading…
Reference in New Issue
Block a user