]> git.proxmox.com Git - qemu-server.git/commitdiff
get_replicatable_volumes: replacemnet for PVE::ReplicationTools::get_syncable_guestdi...
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 6 May 2017 13:11:46 +0000 (15:11 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 6 May 2017 13:11:46 +0000 (15:11 +0200)
correctly scan for volumes inside snapshots.

This will also solve the cyclic package dependency propblem.

PVE/API2/Qemu.pm
PVE/QemuServer.pm

index 091f9e10fc110918a8a3605a0a232659e9814ffa..f5ffb9bdad6e662333b72628d1b7fe876bd6cb43 100644 (file)
@@ -24,7 +24,6 @@ use PVE::INotify;
 use PVE::Network;
 use PVE::Firewall;
 use PVE::API2::Firewall::VM;
-use PVE::ReplicationTools;
 
 BEGIN {
     if (!$ENV{PVE_GENERATING_DOCS}) {
@@ -1052,8 +1051,8 @@ my $update_vm_api  = sub {
 
                    &$create_disks($rpcenv, $authuser, $conf->{pending}, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
                } elsif ($opt eq "replicate") {
-                   die "Not all volumes are syncable, please check your config\n"
-                       if !PVE::ReplicationTools::check_guest_volumes_syncable($conf, 'qemu');
+                   # check if all volumes have replicate feature
+                   PVE::QemuServer::get_replicatable_volumes($storecfg, $conf);
                    my $repl = PVE::JSONSchema::check_format('pve-replicate', $param->{opt});
                    PVE::Cluster::check_node_exists($repl->{target});
                    $conf->{$opt} = $param->{$opt};
index 2fb419db835dbbe043e0892fcd479a0b882d1592..08ac94023346520dfe4593fa02733ac237e0bfbb 100644 (file)
@@ -2776,6 +2776,45 @@ sub foreach_volid {
     }
 }
 
+sub get_replicatable_volumes {
+    my ($storecfg, $conf, $noerr) = @_;
+
+    my $volhash = {};
+
+    my $test_volid = sub {
+       my ($volid, $drive) = @_;
+       
+       return if !$volid;
+
+       return if drive_is_cdrom($drive);
+
+       return if defined($drive->{replicate}) && !$drive->{replicate};
+
+       if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) {
+           return if $noerr;
+           die "missing replicate feature on volume '$volid'\n"; 
+       }
+
+       $volhash->{$volid} = 1;
+    };
+
+    foreach_drive($conf, sub {
+       my ($ds, $drive) = @_;
+       $test_volid->($drive->{file}, $drive);
+    });
+
+    foreach my $snapname (keys %{$conf->{snapshots}}) {
+       my $snap = $conf->{snapshots}->{$snapname};
+       # fixme: what about $snap->{vmstate}
+       foreach_drive($snap, sub {
+           my ($ds, $drive) = @_;
+           $test_volid->($drive->{file}, $drive);
+        });
+    }
+
+    return $volhash;
+}
+
 sub vga_conf_has_spice {
     my ($vga) = @_;