config: ensure definedness for iterating pending & snapshot volumes

while it will work as is, autovivification can be a real PITA so this
should make it more robust and might even avoid having the one or
other warning about accessing undef values in logs.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-03-16 11:46:47 +01:00
parent c788e7c8d1
commit c95b563b7b

View File

@ -508,12 +508,17 @@ sub update_volume_ids {
}; };
$class->foreach_volume_full($conf, $opts, $do_replace, $conf); $class->foreach_volume_full($conf, $opts, $do_replace, $conf);
foreach my $snap (keys %{$conf->{snapshots}}) {
my $snap_conf = $conf->{snapshots}->{$snap}; if (defined($conf->{snapshots})) {
$class->foreach_volume_full($snap_conf, $opts, $do_replace, $snap_conf); for my $snap (keys %{$conf->{snapshots}}) {
my $snap_conf = $conf->{snapshots}->{$snap};
$class->foreach_volume_full($snap_conf, $opts, $do_replace, $snap_conf);
}
} }
$class->foreach_volume_full($conf->{pending}, $opts, $do_replace, $conf->{pending}); if (defined($conf->{pending})) {
$class->foreach_volume_full($conf->{pending}, $opts, $do_replace, $conf->{pending});
}
} }
# Returns whether the template parameter is set in $conf. # Returns whether the template parameter is set in $conf.