get_replicatable_volumes: use PVE::QemuServer::foreach_volid

This commit is contained in:
Dietmar Maurer 2017-06-13 06:58:58 +02:00
parent 392f8b5dff
commit f949eb7760

View File

@ -69,9 +69,7 @@ sub get_replicatable_volumes {
my $volhash = {}; my $volhash = {};
my $test_volid = sub { my $test_volid = sub {
my ($volid, $drive) = @_; my ($volid, $attr) = @_;
return if !$volid;
my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, $noerr); my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, $noerr);
return if !$storeid; return if !$storeid;
@ -79,9 +77,9 @@ sub get_replicatable_volumes {
my $scfg = storage_config($storecfg, $storeid); my $scfg = storage_config($storecfg, $storeid);
return if $scfg->{shared}; return if $scfg->{shared};
return if PVE::QemuServer::drive_is_cdrom($drive); return if $attr->{cdrom};
return if !$cleanup && defined($drive->{replicate}) && !$drive->{replicate}; return if !$cleanup && !$attr->{replicate};
if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) { if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) {
return if $cleanup || $noerr; return if $cleanup || $noerr;
@ -91,19 +89,7 @@ sub get_replicatable_volumes {
$volhash->{$volid} = 1; $volhash->{$volid} = 1;
}; };
PVE::QemuServer::foreach_drive($conf, sub { PVE::QemuServer::foreach_volid($conf, $test_volid);
my ($ds, $drive) = @_;
$test_volid->($drive->{file}, $drive);
});
foreach my $snapname (keys %{$conf->{snapshots}}) {
my $snap = $conf->{snapshots}->{$snapname};
# fixme: what about $snap->{vmstate}
PVE::QemuServer::foreach_drive($snap, sub {
my ($ds, $drive) = @_;
$test_volid->($drive->{file}, $drive);
});
}
return $volhash; return $volhash;
} }