mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-07 08:50:29 +00:00
add sub has_feature
loop over each disk of the vm config file to find if feature is available. If one of the disk doesn't have the feature, we return undef, else return 1 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
135007c099
commit
7ea975efe0
@ -4059,28 +4059,7 @@ my $snapshot_prepare = sub {
|
|||||||
if defined($conf->{snapshots}->{$snapname});
|
if defined($conf->{snapshots}->{$snapname});
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
die "snapshot feature is not available" if !has_feature('snapshot', $conf, $storecfg);
|
||||||
foreach_drive($conf, sub {
|
|
||||||
my ($ds, $drive) = @_;
|
|
||||||
|
|
||||||
return if drive_is_cdrom($drive);
|
|
||||||
my $volid = $drive->{file};
|
|
||||||
|
|
||||||
my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
|
|
||||||
if ($storeid) {
|
|
||||||
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
|
|
||||||
die "can't snapshot volume '$volid'\n"
|
|
||||||
if !(($scfg->{path} && $volname =~ m/\.qcow2$/) ||
|
|
||||||
($scfg->{type} eq 'nexenta') ||
|
|
||||||
($scfg->{type} eq 'rbd') ||
|
|
||||||
($scfg->{type} eq 'sheepdog'));
|
|
||||||
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
|
|
||||||
die "snapshot device '$volid' is not possible\n";
|
|
||||||
} else {
|
|
||||||
die "can't snapshot volume '$volid'\n";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$snap = $conf->{snapshots}->{$snapname} = {};
|
$snap = $conf->{snapshots}->{$snapname} = {};
|
||||||
|
|
||||||
@ -4380,4 +4359,18 @@ sub snapshot_delete {
|
|||||||
lock_config($vmid, $updatefn);
|
lock_config($vmid, $updatefn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub has_feature{
|
||||||
|
my ($feature, $conf, $storecfg, $snapname, $running) = @_;
|
||||||
|
|
||||||
|
my $err = undef;
|
||||||
|
foreach_drive($conf, sub {
|
||||||
|
my ($ds, $drive) = @_;
|
||||||
|
|
||||||
|
return if drive_is_cdrom($drive);
|
||||||
|
my $volid = $drive->{file};
|
||||||
|
$err = 1 if !PVE::Storage::volume_has_feature($storecfg, $feature, $volid, $snapname, $running);
|
||||||
|
});
|
||||||
|
|
||||||
|
return 1 if !$err;
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user