From 25420507b2b97cc2b4559ce8a84f70f684069ad3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 26 Jun 2017 16:34:33 +0200 Subject: [PATCH] refuse to create replication jobs for unreplicatable VMs --- PVE/API2/Replication.pm | 2 +- PVE/API2/ReplicationConfig.pm | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm index 117fe57d..ddfc2d0e 100644 --- a/PVE/API2/Replication.pm +++ b/PVE/API2/Replication.pm @@ -20,7 +20,7 @@ use base qw(PVE::RESTHandler); my $pvesr_lock_path = "/var/lock/pvesr.lck"; -my $lookup_guest_class = sub { +our $lookup_guest_class = sub { my ($vmtype) = @_; if ($vmtype eq 'qemu') { diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm index f5523662..c5ae76f6 100644 --- a/PVE/API2/ReplicationConfig.pm +++ b/PVE/API2/ReplicationConfig.pm @@ -118,11 +118,16 @@ __PACKAGE__->register_method ({ my $nodelist = PVE::Cluster::get_members(); my $vmlist = PVE::Cluster::get_vmlist(); + my $guest_info = $vmlist->{ids}->{$guest}; die "Guest '$guest' does not exists.\n" - if !defined($vmlist->{ids}->{$guest}); + if !defined($guest_info); die "Target '$param->{target}' does not exists.\n" if defined($param->{target}) && !defined($nodelist->{$param->{target}}); + my $guest_class = $PVE::API2::Replication::lookup_guest_class->($guest_info->{type}); + my $guest_conf = $guest_class->load_config($guest); + $guest_class->get_replicatable_volumes(PVE::Storage::config(), $guest, $guest_conf, 0, 0); + my $code = sub { my $cfg = PVE::ReplicationConfig->new(); -- 2.39.5