[pve-devel] [PATCH qemu-server] add is_replicated field to migration check result

Mira Limbeck m.limbeck at proxmox.com
Tue May 12 15:45:23 CEST 2020


For better warnings regarding replicated disks and the ignored target
storage, add the 'is_replicated' field to the migration check result.
This contains the result of the replication checks. The first one checks if
the VM is replicated, and the second one checks if the VM is replicated to
the target node.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 PVE/API2/Qemu.pm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index fd51bf3..f88ea6d 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -3329,7 +3329,11 @@ __PACKAGE__->register_method({
 	    local_resources => {
 		type => 'array',
 		description => "List local resources e.g. pci, usb"
-	    }
+	    },
+	    is_replicated => {
+		type => 'boolean',
+		description => 'Indicates if the VM is replicated to the target node'
+	    },
 	},
     },
     code => sub {
@@ -3382,6 +3386,14 @@ __PACKAGE__->register_method({
 
 	$res->{local_resources} = $local_resources;
 
+	my $repl_conf = PVE::ReplicationConfig->new();
+	if (defined($target)) {
+	    $res->{is_replicated} = ($repl_conf->check_for_existing_jobs($vmid, 1) // 0)
+		&& defined($repl_conf->find_local_replication_job($vmid, $target)) ? 1 : 0;
+	} else {
+	    $res->{is_replicated} = 0;
+	}
+
 	return $res;
 
 
-- 
2.20.1





More information about the pve-devel mailing list