[pve-devel] [PATCH 11/19] phase2 : write target vm config after disk create

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Mar 9 16:55:29 CET 2017


On 02/22/2017 02:33 PM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>   PVE/QemuMigrate.pm | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index 1ca445d..13952cb 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -594,6 +594,25 @@ sub phase2 {
>   
>       die "unable to detect remote migration address\n" if !$raddr;
>   
> +    if ($self->{opts}->{externalcluster}) {
> +
> +	my $conf = PVE::QemuConfig->load_config($vmid);
> +
> +	foreach my $target_drive (keys %{$self->{target_drive}}) {
nit picking:
my $drive instead of target drive would be nicer, as it's only for the 
loop iteration
so we see directly from context that it's a target_drive, and we avoid  
a expression like:
$self->{target_drive}->{$target_drive}->{volid}
> +	    my $drive = PVE::QemuServer::parse_drive($target_drive, $self->{target_drive}->{$target_drive}->{volid});
> +	    $conf->{$target_drive} = PVE::QemuServer::print_drive($vmid, $drive);
> +	}
> +
> +	my $configout = "";
> +	foreach my $opt (keys %$conf) {
> +	    next if $opt eq 'snapshots';
> +	    next if $opt eq 'pending';
> +	    $configout .= "$opt: $conf->{$opt}\n";
> +	}
> +	my $cmdwrite = [@{$self->{rem_ssh}}," /bin/echo -e \"$configout\" > /etc/pve/qemu-server/$targetvmid.conf"];
You already wrote the config in the patch:

phase2 : write vm config to externalcluster new vmid.conf

Why here again? (And imo `qm create? API call could fit better,
we should try to avoid introducing to much wile writes like above, imo)

Further no error checking is done, e.g. the remote node has lost quorum
An API call on the remote node could Incorporated this.


> +	PVE::Tools::run_command($cmdwrite);
> +    }
> +
>       if ($migration_type eq 'secure') {
>   	$self->log('info', "start remote tunnel");
>   





More information about the pve-devel mailing list