mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-30 09:35:51 +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 $conf = $res;
|
||||||
my $descr;
|
my $descr;
|
||||||
|
my $finish_description = sub {
|
||||||
|
if (defined($descr)) {
|
||||||
|
$descr =~ s/\s+$//;
|
||||||
|
$conf->{description} = $descr;
|
||||||
|
}
|
||||||
|
$descr = undef;
|
||||||
|
};
|
||||||
my $section = '';
|
my $section = '';
|
||||||
|
|
||||||
my @lines = split(/\n/, $raw);
|
my @lines = split(/\n/, $raw);
|
||||||
@ -2433,11 +2440,7 @@ sub parse_vm_config {
|
|||||||
|
|
||||||
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
||||||
$section = 'pending';
|
$section = 'pending';
|
||||||
if (defined($descr)) {
|
$finish_description->();
|
||||||
$descr =~ s/\s+$//;
|
|
||||||
$conf->{description} = $descr;
|
|
||||||
}
|
|
||||||
$descr = undef;
|
|
||||||
$conf = $res->{$section} = {};
|
$conf = $res->{$section} = {};
|
||||||
next;
|
next;
|
||||||
} elsif ($line =~ m/^\[special:cloudinit\]\s*$/i) {
|
} 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) {
|
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
|
||||||
$section = $1;
|
$section = $1;
|
||||||
if (defined($descr)) {
|
$finish_description->();
|
||||||
$descr =~ s/\s+$//;
|
|
||||||
$conf->{description} = $descr;
|
|
||||||
}
|
|
||||||
$descr = undef;
|
|
||||||
$conf = $res->{snapshots}->{$section} = {};
|
$conf = $res->{snapshots}->{$section} = {};
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -2506,10 +2505,7 @@ sub parse_vm_config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($descr)) {
|
$finish_description->();
|
||||||
$descr =~ s/\s+$//;
|
|
||||||
$conf->{description} = $descr;
|
|
||||||
}
|
|
||||||
delete $res->{snapstate}; # just to be sure
|
delete $res->{snapstate}; # just to be sure
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
Loading…
Reference in New Issue
Block a user