mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2025-01-14 19:24:33 +03:00
Storage Plugins: extend clone_image by snap parameter and add support to RBDPlugin
Signed-off-by: Stefan Priebe <s.priebe@profihost.ag>
This commit is contained in:
parent
2362bc8798
commit
f236eaf80e
@ -104,7 +104,7 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
die "can't clone images in iscsi storage\n";
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
die "can't clone images in iscsi storage\n";
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
die "can't clone images in lvm storage\n";
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ my $find_free_diskname = sub {
|
||||
};
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
# this only works for file based storage types
|
||||
die "storage definintion has no path\n" if !$scfg->{path};
|
||||
@ -497,7 +497,9 @@ sub clone_image {
|
||||
|
||||
die "clone_image on wrong vtype '$vtype'\n" if $vtype ne 'images';
|
||||
|
||||
die "clone_image onyl works on base images\n" if !$isBase;
|
||||
die "this storage type does not support clone_image on snapshot\n" if $snap;
|
||||
|
||||
die "clone_image only works on base images\n" if !$isBase;
|
||||
|
||||
my $imagedir = $class->get_subdir($scfg, 'images');
|
||||
$imagedir .= "/$vmid";
|
||||
|
@ -340,20 +340,31 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_;
|
||||
|
||||
my $snap = '__base__';
|
||||
$snap = $snapname if length $snapname;
|
||||
|
||||
my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
|
||||
$class->parse_volname($volname);
|
||||
|
||||
die "clone_image onyl works on base images\n" if !$isBase;
|
||||
die "$volname is not a base image and snapname is not provided\n" if !$isBase && !length $snapname;
|
||||
|
||||
my $name = &$find_free_diskname($storeid, $scfg, $vmid);
|
||||
|
||||
warn "clone $volname: $basename to $name\n";
|
||||
warn "clone $volname: $basename snapname $snap to $name\n";
|
||||
|
||||
if (length $snapname) {
|
||||
my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $volname, $snapname);
|
||||
|
||||
if (!$protected){
|
||||
my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'protect', $volname, '--snap', $snapname);
|
||||
run_rbd_command($cmd, errmsg => "rbd protect $volname snap $snapname error");
|
||||
}
|
||||
}
|
||||
|
||||
my $newvol = "$basename/$name";
|
||||
$newvol = $name if length $snapname;
|
||||
|
||||
my $cmd = &$rbd_cmd($scfg, $storeid, 'clone', &$add_pool_to_disk($scfg, $basename), '--snap', $snap, &$add_pool_to_disk($scfg, $name));
|
||||
run_rbd_command($cmd, errmsg => "rbd clone '$basename' error");
|
||||
|
@ -215,9 +215,9 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
my $snap = '__base__';
|
||||
$snap ||= '__base__';
|
||||
|
||||
my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
|
||||
$class->parse_volname($volname);
|
||||
|
@ -449,9 +449,9 @@ sub create_base {
|
||||
}
|
||||
|
||||
sub clone_image {
|
||||
my ($class, $scfg, $storeid, $volname, $vmid) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
|
||||
|
||||
my $snap = '__base__';
|
||||
$snap ||= '__base__';
|
||||
|
||||
my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
|
||||
$class->parse_volname($volname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user