[pve-devel] [qemu-server 2/5] PVE::QemuServer::foreach_volid - pass $attr hash to callback
Dietmar Maurer
dietmar at proxmox.com
Tue Jun 13 08:38:55 CEST 2017
That way we can pass more informations, i.e. the 'replicate' attribute.
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/QemuServer.pm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0efab21..758b56a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2776,24 +2776,28 @@ sub foreach_volid {
my $volhash = {};
my $test_volid = sub {
- my ($volid, $is_cdrom) = @_;
+ my ($volid, $is_cdrom, $replicate) = @_;
return if !$volid;
- $volhash->{$volid} = $is_cdrom || 0;
+ $volhash->{$volid}->{cdrom} //= 1;
+ $volhash->{$volid}->{cdrom} = 0 if !$is_cdrom;
+
+ $volhash->{$volid}->{replicate} //= 0;
+ $volhash->{$volid}->{replicate} = 1 if $replicate;
};
foreach_drive($conf, sub {
my ($ds, $drive) = @_;
- &$test_volid($drive->{file}, drive_is_cdrom($drive));
+ &$test_volid($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1);
});
foreach my $snapname (keys %{$conf->{snapshots}}) {
my $snap = $conf->{snapshots}->{$snapname};
- &$test_volid($snap->{vmstate}, 0);
+ &$test_volid($snap->{vmstate}, 0, 1);
foreach_drive($snap, sub {
my ($ds, $drive) = @_;
- &$test_volid($drive->{file}, drive_is_cdrom($drive));
+ &$test_volid($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1);
});
}
@@ -4846,7 +4850,7 @@ sub get_vm_volumes {
my $vollist = [];
foreach_volid($conf, sub {
- my ($volid, $is_cdrom) = @_;
+ my ($volid, $attr) = @_;
return if $volid =~ m|^/|;
--
2.11.0
More information about the pve-devel
mailing list