mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-10-17 22:36:05 +00:00
Insert new properties in the Qemu config for the PVE Replica.
This patch will include all necessary properties for the replication. Also will it enable and disable a replication job when appointed flags are set or deleted.
This commit is contained in:
parent
6e9d255038
commit
9edac22f5f
@ -24,6 +24,7 @@ use PVE::INotify;
|
||||
use PVE::Network;
|
||||
use PVE::Firewall;
|
||||
use PVE::API2::Firewall::VM;
|
||||
use PVE::ReplicationTools;
|
||||
|
||||
BEGIN {
|
||||
if (!$ENV{PVE_GENERATING_DOCS}) {
|
||||
@ -1028,6 +1029,16 @@ my $update_vm_api = sub {
|
||||
if defined($conf->{pending}->{$opt});
|
||||
PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force);
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
} elsif ($opt eq "replica" || $opt eq "replica_target") {
|
||||
delete $conf->{$opt};
|
||||
delete $conf->{replica} if $opt eq "replica_target";
|
||||
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
PVE::ReplicationTools::job_remove($vmid);
|
||||
} elsif ($opt eq "replica_interval" || $opt eq "replica_rate_limit") {
|
||||
delete $conf->{$opt};
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
PVE::ReplicationTools::update_conf($vmid, $opt, $param->{$opt});
|
||||
} else {
|
||||
PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force);
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
@ -1050,6 +1061,21 @@ my $update_vm_api = sub {
|
||||
if defined($conf->{pending}->{$opt});
|
||||
|
||||
&$create_disks($rpcenv, $authuser, $conf->{pending}, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
|
||||
} elsif ($opt eq "replica") {
|
||||
die "Not all volumes are syncable, please check your config\n"
|
||||
if !PVE::ReplicationTools::check_guest_volumes_syncable($conf, 'qemu');
|
||||
die "replica_target is required\n"
|
||||
if !$conf->{replica_target} && !$param->{replica_target};
|
||||
$conf->{$opt} = $param->{$opt};
|
||||
} elsif ($opt eq "replica_interval" || $opt eq "replica_rate_limit") {
|
||||
$conf->{$opt} = $param->{$opt};
|
||||
PVE::ReplicationTools::update_conf($vmid, $opt, $param->{$opt});
|
||||
} elsif ($opt eq "replica_target" ) {
|
||||
die "Node: $param->{$opt} does not exists in Cluster.\n"
|
||||
if !PVE::Cluster::check_node_exists($param->{$opt});
|
||||
PVE::ReplicationTools::update_conf($vmid, $opt, $param->{$opt})
|
||||
if defined($conf->{$opt});
|
||||
$conf->{$opt} = $param->{$opt};
|
||||
} else {
|
||||
$conf->{pending}->{$opt} = $param->{$opt};
|
||||
}
|
||||
@ -1057,6 +1083,14 @@ my $update_vm_api = sub {
|
||||
PVE::QemuConfig->write_config($vmid, $conf);
|
||||
}
|
||||
|
||||
if (defined($param->{replica})) {
|
||||
if ($param->{replica}) {
|
||||
PVE::ReplicationTools::job_enable($vmid);
|
||||
} else {
|
||||
PVE::ReplicationTools::job_disable($vmid);
|
||||
}
|
||||
}
|
||||
|
||||
# remove pending changes when nothing changed
|
||||
$conf = PVE::QemuConfig->load_config($vmid); # update/reload
|
||||
my $changes = PVE::QemuServer::vmconfig_cleanup_pending($conf);
|
||||
|
@ -491,6 +491,31 @@ EODESCR
|
||||
maxLength => 256,
|
||||
optional => 1,
|
||||
},
|
||||
replica => {
|
||||
optional => 1,
|
||||
description => "Storage replica for local storage.",
|
||||
type => 'boolean',
|
||||
default => 0,
|
||||
},
|
||||
replica_rate_limit => {
|
||||
optional => 1,
|
||||
description => "Storage replica rate limit in KBytes/s.",
|
||||
type => 'integer',
|
||||
minimum => 1,
|
||||
},
|
||||
replica_interval => {
|
||||
optional => 1,
|
||||
description => "Storage replica sync interval",
|
||||
type => 'integer',
|
||||
minimum => 1,
|
||||
maximum => 1440,
|
||||
default => 15,
|
||||
},
|
||||
replica_target => {
|
||||
optional => 1,
|
||||
description => "Storage replica taget node.",
|
||||
type => 'string',
|
||||
},
|
||||
protection => {
|
||||
optional => 1,
|
||||
type => 'boolean',
|
||||
@ -747,6 +772,12 @@ my %drivedesc_base = (
|
||||
description => "Whether the drive should be included when making backups.",
|
||||
optional => 1,
|
||||
},
|
||||
replica => {
|
||||
type => 'boolean',
|
||||
description => 'Will include this drive to an storage replical job.',
|
||||
optional => 1,
|
||||
default => 1,
|
||||
},
|
||||
rerror => {
|
||||
type => 'string',
|
||||
enum => [qw(ignore report stop)],
|
||||
|
Loading…
Reference in New Issue
Block a user