mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-02 05:37:19 +00:00
move get_replicatable_volumes from QemuServer.pm to QemuConfig.pm
This commit is contained in:
parent
64932aebff
commit
3aa44d3b57
@ -1055,7 +1055,7 @@ my $update_vm_api = sub {
|
|||||||
&$create_disks($rpcenv, $authuser, $conf->{pending}, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
|
&$create_disks($rpcenv, $authuser, $conf->{pending}, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
|
||||||
} elsif ($opt eq "replicate") {
|
} elsif ($opt eq "replicate") {
|
||||||
# check if all volumes have replicate feature
|
# check if all volumes have replicate feature
|
||||||
PVE::QemuServer::get_replicatable_volumes($storecfg, $conf);
|
PVE::QemuConfig->get_replicatable_volumes($storecfg, $conf);
|
||||||
my $repl = PVE::JSONSchema::check_format('pve-replicate', $param->{opt});
|
my $repl = PVE::JSONSchema::check_format('pve-replicate', $param->{opt});
|
||||||
PVE::Cluster::check_node_exists($repl->{target});
|
PVE::Cluster::check_node_exists($repl->{target});
|
||||||
$conf->{$opt} = $param->{$opt};
|
$conf->{$opt} = $param->{$opt};
|
||||||
|
@ -63,6 +63,45 @@ sub has_feature {
|
|||||||
return $err ? 0 : 1;
|
return $err ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_replicatable_volumes {
|
||||||
|
my ($class, $storecfg, $conf, $noerr) = @_;
|
||||||
|
|
||||||
|
my $volhash = {};
|
||||||
|
|
||||||
|
my $test_volid = sub {
|
||||||
|
my ($volid, $drive) = @_;
|
||||||
|
|
||||||
|
return if !$volid;
|
||||||
|
|
||||||
|
return if PVE::QemuServer::drive_is_cdrom($drive);
|
||||||
|
|
||||||
|
return if defined($drive->{replicate}) && !$drive->{replicate};
|
||||||
|
|
||||||
|
if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) {
|
||||||
|
return if $noerr;
|
||||||
|
die "missing replicate feature on volume '$volid'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$volhash->{$volid} = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
PVE::QemuServer::foreach_drive($conf, sub {
|
||||||
|
my ($ds, $drive) = @_;
|
||||||
|
$test_volid->($drive->{file}, $drive);
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach my $snapname (keys %{$conf->{snapshots}}) {
|
||||||
|
my $snap = $conf->{snapshots}->{$snapname};
|
||||||
|
# fixme: what about $snap->{vmstate}
|
||||||
|
PVE::QemuServer::foreach_drive($snap, sub {
|
||||||
|
my ($ds, $drive) = @_;
|
||||||
|
$test_volid->($drive->{file}, $drive);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return $volhash;
|
||||||
|
}
|
||||||
|
|
||||||
sub __snapshot_save_vmstate {
|
sub __snapshot_save_vmstate {
|
||||||
my ($class, $vmid, $conf, $snapname, $storecfg) = @_;
|
my ($class, $vmid, $conf, $snapname, $storecfg) = @_;
|
||||||
|
|
||||||
|
@ -2776,45 +2776,6 @@ sub foreach_volid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_replicatable_volumes {
|
|
||||||
my ($storecfg, $conf, $noerr) = @_;
|
|
||||||
|
|
||||||
my $volhash = {};
|
|
||||||
|
|
||||||
my $test_volid = sub {
|
|
||||||
my ($volid, $drive) = @_;
|
|
||||||
|
|
||||||
return if !$volid;
|
|
||||||
|
|
||||||
return if drive_is_cdrom($drive);
|
|
||||||
|
|
||||||
return if defined($drive->{replicate}) && !$drive->{replicate};
|
|
||||||
|
|
||||||
if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) {
|
|
||||||
return if $noerr;
|
|
||||||
die "missing replicate feature on volume '$volid'\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$volhash->{$volid} = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach_drive($conf, sub {
|
|
||||||
my ($ds, $drive) = @_;
|
|
||||||
$test_volid->($drive->{file}, $drive);
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach my $snapname (keys %{$conf->{snapshots}}) {
|
|
||||||
my $snap = $conf->{snapshots}->{$snapname};
|
|
||||||
# fixme: what about $snap->{vmstate}
|
|
||||||
foreach_drive($snap, sub {
|
|
||||||
my ($ds, $drive) = @_;
|
|
||||||
$test_volid->($drive->{file}, $drive);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return $volhash;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub vga_conf_has_spice {
|
sub vga_conf_has_spice {
|
||||||
my ($vga) = @_;
|
my ($vga) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user