[pve-devel] [PATCH v3 container 3/5] use copy_volume for full clones
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Sep 26 14:43:02 CEST 2017
---
No changes.
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 0397224..ac3eefa 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1191,6 +1191,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();
@@ -1244,10 +1247,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
@@ -1298,17 +1299,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.11.0
More information about the pve-devel
mailing list