]> git.proxmox.com Git - qemu-server.git/commitdiff
Repeat check for replication target in locked section
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 29 Oct 2020 13:31:30 +0000 (14:31 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 9 Nov 2020 09:08:22 +0000 (10:08 +0100)
No need to warn twice, so the warning from the outside check
was removed.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuMigrate.pm

index e8de4eac9a659e40070d8f0c344a0306976272e2..bef83df7f1381dd5dd45479ac10e2e551874d9ec 100644 (file)
@@ -3568,14 +3568,9 @@ __PACKAGE__->register_method({
            my $repl_conf = PVE::ReplicationConfig->new();
            my $is_replicated = $repl_conf->check_for_existing_jobs($vmid, 1);
            my $is_replicated_to_target = defined($repl_conf->find_local_replication_job($vmid, $target));
-           if ($is_replicated && !$is_replicated_to_target) {
-               if ($param->{force}) {
-                   warn "WARNING: Node '$target' is not a replication target. Existing replication " .
-                        "jobs will fail after migration!\n";
-               } else {
-                   die "Cannot live-migrate replicated VM to node '$target' - not a replication target." .
-                       " Use 'force' to override.\n";
-               }
+           if (!$param->{force} && $is_replicated && !$is_replicated_to_target) {
+               die "Cannot live-migrate replicated VM to node '$target' - not a replication " .
+                   "target. Use 'force' to override.\n";
            }
        } else {
            warn "VM isn't running. Doing offline migration instead.\n" if $param->{online};
index 2f4eec334e42d7af3a824d97e197b4cbec5ad4ec..a8bcd15fba1745689b9a586368af3c1ce6a7c77d 100644 (file)
@@ -227,6 +227,19 @@ sub prepare {
        die "can't migrate running VM without --online\n" if !$online;
        $running = $pid;
 
+       my $repl_conf = PVE::ReplicationConfig->new();
+       my $is_replicated = $repl_conf->check_for_existing_jobs($vmid, 1);
+       my $is_replicated_to_target = defined($repl_conf->find_local_replication_job($vmid, $self->{node}));
+       if ($is_replicated && !$is_replicated_to_target) {
+           if ($self->{opts}->{force}) {
+               $self->log('warn', "WARNING: Node '$self->{node}' is not a replication target. Existing " .
+                                  "replication jobs will fail after migration!\n");
+           } else {
+               die "Cannot live-migrate replicated VM to node '$self->{node}' - not a replication " .
+                   "target. Use 'force' to override.\n";
+           }
+       }
+
        $self->{forcemachine} = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf);
 
        # To support custom CPU types, we keep QEMU's "-cpu" parameter intact.