description => "Setup public SSH keys (one key per line, " .
"OpenSSH format).",
},
+ bwlimit => {
+ description => "Override i/o bandwidth limit (in KiB/s).",
+ optional => 1,
+ type => 'number',
+ minimum => '0',
+ },
}),
},
returns => {
my $ignore_unpack_errors = extract_param($param, 'ignore-unpack-errors');
+ my $bwlimit = extract_param($param, 'bwlimit');
+
my $basecfg_fn = PVE::LXC::Config->config_file($vmid);
my $same_container_exists = -f $basecfg_fn;
$archive = PVE::Storage::abs_filesystem_path($storage_cfg, $ostemplate);
}
+ my %used_storages;
my $check_and_activate_storage = sub {
my ($sid) = @_;
$rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
PVE::Storage::activate_storage($storage_cfg, $sid);
+
+ $used_storages{$sid} = 1;
};
my $conf = {};
eval {
my $rootdir = PVE::LXC::mount_all($vmid, $storage_cfg, $conf, 1);
- PVE::LXC::Create::restore_archive($archive, $rootdir, $conf, $ignore_unpack_errors);
+ $bwlimit = PVE::Storage::get_bandwidth_limit('restore', [keys %used_storages], $bwlimit);
+ PVE::LXC::Create::restore_archive($archive, $rootdir, $conf, $ignore_unpack_errors, $bwlimit);
if ($restore) {
PVE::LXC::Create::restore_configuration($vmid, $rootdir, $conf, $authuser ne 'root@pam');
}
sub restore_archive {
- my ($archive, $rootdir, $conf, $no_unpack_error) = @_;
+ my ($archive, $rootdir, $conf, $no_unpack_error, $bwlimit) = @_;
my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf);
my $userns_cmd = PVE::LXC::userns_command($id_map);
push @$cmd, '--anchored';
push @$cmd, '--exclude' , './dev/*';
+ if (defined($bwlimit)) {
+ $cmd = [ ['cstream', '-t', $bwlimit*1024], $cmd ];
+ }
+
if ($archive eq '-') {
print "extracting archive from STDIN\n";
} else {