[pve-devel] [PATCH container 3/4] use copy_volume for full clones
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Dec 2 15:44:18 CET 2016
---
src/PVE/API2/LXC.pm | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 38b1feb..fe611b0 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1147,6 +1147,9 @@ __PACKAGE__->register_method({
my $storage = extract_param($param, 'storage');
+ die "Full clone requires a target storage.\n"
+ if $param->{full} && !$storage;
+
my $localnode = PVE::INotify::nodename();
my $storecfg = PVE::Storage::config();
@@ -1200,10 +1203,8 @@ __PACKAGE__->register_method({
if ($mp->{type} eq 'volume') {
my $volid = $mp->{volume};
if ($param->{full}) {
- die "fixme: full clone not implemented";
-
- die "Full clone feature for '$volid' is not available\n"
- if !PVE::Storage::volume_has_feature($storecfg, 'copy', $volid, $snapname, $running);
+ die "Cannot do full clones on a running container without snapshots\n"
+ if $running && !defined($snapname);
$fullclone->{$opt} = 1;
} else {
# not full means clone instead of copy
@@ -1251,17 +1252,20 @@ __PACKAGE__->register_method({
my $mp = $mountpoints->{$opt};
my $volid = $mp->{volume};
+ my $newvolid;
if ($fullclone->{$opt}) {
- die "fixme: full clone not implemented\n";
+ print "create full clone of mountpoint $opt ($volid)\n";
+ $newvolid = PVE::LXC::copy_volume($mp, $newid, $storage, $storecfg, $conf, $snapname);
} else {
print "create linked clone of mount point $opt ($volid)\n";
- my $newvolid = PVE::Storage::vdisk_clone($storecfg, $volid, $newid, $snapname);
- push @$newvollist, $newvolid;
- $mp->{volume} = $newvolid;
-
- $newconf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp, $opt eq 'rootfs');
- PVE::LXC::Config->write_config($newid, $newconf);
+ $newvolid = PVE::Storage::vdisk_clone($storecfg, $volid, $newid, $snapname);
}
+
+ push @$newvollist, $newvolid;
+ $mp->{volume} = $newvolid;
+
+ $newconf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp, $opt eq 'rootfs');
+ PVE::LXC::Config->write_config($newid, $newconf);
}
delete $newconf->{lock};
--
2.1.4
More information about the pve-devel
mailing list