[pve-devel] [qemu-server 4/5] PVE::QemuServer::foreach_volid - record snapshot references
Dietmar Maurer
dietmar at proxmox.com
Tue Jun 13 08:38:57 CEST 2017
So that we can test if a volume is referenced in the main config, and/or
inside a snapshot config.
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/QemuServer.pm | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 758b56a..1a4860e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2776,7 +2776,7 @@ sub foreach_volid {
my $volhash = {};
my $test_volid = sub {
- my ($volid, $is_cdrom, $replicate) = @_;
+ my ($volid, $is_cdrom, $replicate, $snapname) = @_;
return if !$volid;
@@ -2785,19 +2785,25 @@ sub foreach_volid {
$volhash->{$volid}->{replicate} //= 0;
$volhash->{$volid}->{replicate} = 1 if $replicate;
+
+ $volhash->{$volid}->{referenced_in_config} //= 0;
+ $volhash->{$volid}->{referenced_in_config} = 1 if !defined($snapname);
+
+ $volhash->{$volid}->{referenced_in_snapshot}->{$snapname} = 1
+ if defined($snapname);
};
foreach_drive($conf, sub {
my ($ds, $drive) = @_;
- &$test_volid($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1);
+ $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, undef);
});
foreach my $snapname (keys %{$conf->{snapshots}}) {
my $snap = $conf->{snapshots}->{$snapname};
- &$test_volid($snap->{vmstate}, 0, 1);
+ $test_volid->($snap->{vmstate}, 0, 1, $snapname);
foreach_drive($snap, sub {
my ($ds, $drive) = @_;
- &$test_volid($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1);
+ $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, $snapname);
});
}
--
2.11.0
More information about the pve-devel
mailing list