]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/LVMPlugin.pm
fix #3555: BTRFS: call DirPlugin's free_image correctly
[pve-storage.git] / PVE / Storage / LVMPlugin.pm
index 73e8e487a397e24022d274fb5ef0870e16847ae1..139d391eacd3befc6b714f2ed5792f085a68ade3 100644 (file)
@@ -330,7 +330,7 @@ sub lvcreate {
        $size .= "k"; # default to kilobytes
     }
 
-    my $cmd = ['/sbin/lvcreate', '-aly', '--size', $size, '--name', $name];
+    my $cmd = ['/sbin/lvcreate', '-aly', '-Wy', '--yes', '--size', $size, '--name', $name];
     for my $tag (@$tags) {
        push @$cmd, '--addtag', $tag;
     }
@@ -344,7 +344,7 @@ sub alloc_image {
 
     die "unsupported format '$fmt'" if $fmt ne 'raw';
 
-    die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
+    die "illegal name '$name' - should be 'vm-$vmid-*'\n"
        if  $name && $name !~ m/^vm-$vmid-/;
 
     my $vgs = lvm_vgs();
@@ -446,7 +446,8 @@ sub list_images {
 
            next if $scfg->{tagged_only} && !&$check_tags($info->{tags});
 
-           next if $info->{lv_type} ne '-';
+           # Allow mirrored and RAID LVs
+           next if $info->{lv_type} !~ m/^[-mMrR]$/;
 
            my $volid = "$storeid:$volname";
 
@@ -602,7 +603,7 @@ sub volume_has_feature {
 sub volume_export_formats {
     my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
     return () if defined($snapshot); # lvm-thin only
-    return volume_import_formats($class, $scfg, $storeid, $volname, $base_snapshot, $with_snapshots);
+    return volume_import_formats($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots);
 }
 
 sub volume_export {
@@ -626,14 +627,14 @@ sub volume_export {
 }
 
 sub volume_import_formats {
-    my ($class, $scfg, $storeid, $volname, $base_snapshot, $with_snapshots) = @_;
+    my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
     return () if $with_snapshots; # not supported
     return () if defined($base_snapshot); # not supported
     return ('raw+size');
 }
 
 sub volume_import {
-    my ($class, $scfg, $storeid, $fh, $volname, $format, $base_snapshot, $with_snapshots, $allow_rename) = @_;
+    my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots, $allow_rename) = @_;
     die "volume import format $format not available for $class\n"
        if $format ne 'raw+size';
     die "cannot import volumes together with their snapshots in $class\n"
@@ -669,8 +670,16 @@ sub volume_import {
        $class->volume_import_write($fh, $file);
     };
     if (my $err = $@) {
-       eval { $class->free_image($storeid, $scfg, $volname, 0) };
+       my $cleanup_worker = eval { $class->free_image($storeid, $scfg, $volname, 0) };
        warn $@ if $@;
+
+       if ($cleanup_worker) {
+           my $rpcenv = PVE::RPCEnvironment::get();
+           my $authuser = $rpcenv->get_user();
+
+           $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
+       }
+
        die $err;
     }