[pve-devel] [PATCH v3 pve-manager 16/23] PVE::Replication::replicate - implement replicate

Wolfgang Link w.link at proxmox.com
Wed May 31 10:33:24 CEST 2017


Comment inline

On 05/30/2017 03:20 PM, Dietmar Maurer wrote:
> diff --git a/PVE/Replication.pm b/PVE/Replication.pm
> index ee0b841b..d235b49d 100644
> --- a/PVE/Replication.pm
> +++ b/PVE/Replication.pm
> @@ -219,12 +219,138 @@ sub prepare {
>      return $last_snapshots;
>  }
>
> -sub replicate {
> -    my ($jobcfg, $start_time, $logfunc) = @_;
> +sub replicate_volume {
> +    my ($ssh_info, $storecfg, $volid, $base_snapshot, $sync_snapname) = @_;
>
>      die "implement me";
>  }
>
> +sub replicate {
> +    my ($jobcfg, $last_sync, $start_time, $logfunc) = @_;
> +
> +    $logfunc = sub {} if !$logfunc; # log nothing by default
> +
> +    my $local_node = PVE::INotify::nodename();
> +
> +    die "not implemented - internal error" if $jobcfg->{type} ne 'local';
> +
> +    my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
> +    my $migration_network = $dc_conf->{migration_network};
> +    my $ssh_info = PVE::Cluster::get_ssh_info($jobcfg->{target}, $migration_network);
> +
> +    my $jobid = $jobcfg->{id};
> +    my $storecfg = PVE::Storage::config();
> +
> +    die "start time before last sync ($start_time <= $last_sync) - abort sync\n"
> +	if $start_time <= $last_sync;
> +
> +    my $vmid = $jobcfg->{guest};
> +    my $vmtype = $jobcfg->{vmtype};
> +
> +    my $conf;
> +    my $running;
> +    my $qga;
> +    my $volumes;
> +
> +    if ($vmtype eq 'qemu') {
> +	$conf = PVE::QemuConfig->load_config($vmid);
> +	$running = PVE::QemuServer::check_running($vmid);
> +	$qga = PVE::QemuServer::qga_check_running($vmid)
> +	    if $running && $conf->{agent};
> +	$volumes = PVE::QemuConfig->get_replicatable_volumes($storecfg, $conf);
> +    } elsif ($vmtype eq 'lxc') {
> +	$conf = PVE::LXC::Config->load_config($vmid);
> +	$running = PVE::LXC::check_running($vmid);
> +	$volumes = PVE::LXC::Config->get_replicatable_volumes($storecfg, $conf);
> +    } else {
> +	die "internal error";
> +    }
> +
> +    my $sorted_volids = [ sort keys %$volumes ];
> +
> +    $logfunc->($start_time, "$jobid: guest => $vmid, type => $vmtype, running => $running");
Qemu and also LXC will return undef if the guest is not running.
We get an warning here if the guest is not running.




More information about the pve-devel mailing list