with T-B included.

since this is pre-config-lock and outside the flocked section, it might 
make sense to repeat the check in QemuMigrate? then again, 
creating/deleting replication jobs only locks the replication config and 
not the VM config, so without changes there it won't be race-free 
either.

On May 18, 2020 9:37 am, Fabian Ebner wrote:
> Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
> ---
> 
> Changes from v1:
>     * die/warn depending on force (thanks to Thomas and Aaron for the 
> suggestion)
>     * don't die/warn if VM is not replicated at all
> 
>  PVE/API2/Qemu.pm | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index fd51bf3..cb99f78 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -3486,6 +3486,19 @@ __PACKAGE__->register_method({
>  
>       if (PVE::QemuServer::check_running($vmid)) {
>           die "can't migrate running VM without --online\n" if 
> !$param->{online};
> +
> +         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";
> +             }
> +         }
>       } else {
>           warn "VM isn't running. Doing offline migration instead.\n" if 
> $param->{online};
>           $param->{online} = 0;
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-de...@pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to