lvm_create_volume_group($path, $scfg->{vgname}, $scfg->{shared});
}
+
+ return;
}
sub parse_volname {
$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;
}
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();
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";
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 {
}
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"
$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;
}