]> git.proxmox.com Git - qemu-server.git/blobdiff - qmextract
d/control: remove unused dependency
[qemu-server.git] / qmextract
index 3b2544564e117e62fac58bea879f6a08edad07d3..1466a586d9163ec31c3f7976a07a6046f3f64f7e 100755 (executable)
--- 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';
@@ -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";
     }
 }