X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qmextract;h=1466a586d9163ec31c3f7976a07a6046f3f64f7e;hb=1e5143de74496a86b0ff4c550dc22aa4ce5d17b3;hp=dbcee8772919f2bc90a4b267517017c0adc757e3;hpb=a0d1b1a2fecc1d33e4728f289d03028d9efc8594;p=qemu-server.git diff --git a/qmextract b/qmextract index dbcee87..1466a58 100755 --- a/qmextract +++ b/qmextract @@ -1,14 +1,16 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; use Getopt::Long; use File::Path; use IO::File; use PVE::INotify; use PVE::JSONSchema; use PVE::Tools; -use PVE::Cluster qw(cfs_read_file); +use PVE::Cluster; use PVE::RPCEnvironment; +use PVE::Storage; use PVE::QemuServer; $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; @@ -142,12 +144,12 @@ sub extract_archive { if ($user ne 'root@pam') { if (defined($opts->{storage})) { my $sid = $opts->{storage} || 'local'; - $rpcenv->check_storage_perm($user, $vmid, $pool, $sid, ['Datastore.AllocateSpace']); + $rpcenv->check($user, "/storage/$sid", ['Datastore.AllocateSpace']); } else { foreach my $fn (keys %$map) { my $fi = $map->{$fn}; my $sid = $fi->{storeid} || 'local'; - $rpcenv->check_storage_perm($user, $vmid, $pool, $sid, ['Datastore.AllocateSpace']); + $rpcenv->check($user, "/storage/$sid", ['Datastore.AllocateSpace']); } } } @@ -159,10 +161,10 @@ sub extract_archive { $storeid = $info->{storeid} || 'local'; } - my $cfg = cfs_read_file('storage.cfg'); + my $cfg = PVE::Storage::config(); my $scfg = PVE::Storage::storage_config($cfg, $storeid); - my $alloc_size = ($filesize + 1024 - 1)/1024; + my $alloc_size = int(($filesize + 1024 - 1)/1024); if ($scfg->{type} eq 'dir' || $scfg->{type} eq 'nfs') { # hack: we just alloc a small file (32K) - we overwrite it anyways $alloc_size = 32; @@ -189,8 +191,8 @@ sub extract_archive { exec 'dd', 'ibs=256K', 'obs=256K', "of=$path"; die "couldn't exec dd: $!\n"; } else { - exec '/usr/lib/qemu-server/sparsecp', $path; - die "couldn't exec sparsecp: $!\n"; + exec '/bin/cp', '--sparse=always', '/dev/stdin', $path; + die "couldn't exec cp: $!\n"; } }