]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/Plugin.pm
use File::chdir instead of Cwd
[pve-storage.git] / PVE / Storage / Plugin.pm
index de2818cd62d0aab634258d27c54aba26ec123ed7..462d9e1e21d40d66b8545aadfd46669a10b986d8 100644 (file)
@@ -2,7 +2,7 @@ package PVE::Storage::Plugin;
 
 use strict;
 use warnings;
-use Cwd;
+use File::chdir;
 use File::Path;
 use PVE::Tools qw(run_command);
 use PVE::JSONSchema qw(get_standard_option);
@@ -506,10 +506,9 @@ sub clone_image {
 
     my $path = $class->path($scfg, $newvol);
 
-    # Note: we use relative paths, so we need to call chdir before qemu-img
-    my $oldcwd = cwd();
+    # Note: we use relative paths, so we need to call chdir before qemu-img  
     eval {
-       chdir $imagedir;
+       local $CWD = $imagedir;
 
        my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename", 
                   '-f', 'qcow2', $path];
@@ -518,8 +517,6 @@ sub clone_image {
     };
     my $err = $@;
 
-    chdir $oldcwd;
-
     die $err if $err;
 
     return $newvol;