diff --git a/PVE/Storage/GlusterfsPlugin.pm b/PVE/Storage/GlusterfsPlugin.pm index 1f9465f..b3e5553 100644 --- a/PVE/Storage/GlusterfsPlugin.pm +++ b/PVE/Storage/GlusterfsPlugin.pm @@ -274,7 +274,12 @@ sub alloc_image { push @$cmd, '-f', $fmt, $volumepath, "${size}K"; - run_command($cmd, errmsg => "unable to create image"); + eval { run_command($cmd, errmsg => "unable to create image"); }; + if ($@) { + unlink $path; + rmdir $imagedir; + die "$@"; + } return "$vmid/$name"; } diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 10c2c73..7964441 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -665,7 +665,12 @@ sub alloc_image { push @$cmd, '-f', $fmt, $path, "${size}K"; - run_command($cmd, errmsg => "unable to create image"); + eval { run_command($cmd, errmsg => "unable to create image"); }; + if ($@) { + unlink $path; + rmdir $imagedir; + die "$@"; + } } return "$vmid/$name";