server2 => { optional => 1 },
volume => { fixed => 1 },
transport => { optional => 1 },
- nodes => { optional => 1 },
+ nodes => { optional => 1 },
disable => { optional => 1 },
- maxfiles => { optional => 1 },
+ maxfiles => { optional => 1 },
+ 'prune-backups' => { optional => 1 },
content => { optional => 1 },
format => { optional => 1 },
mkdir => { optional => 1 },
bwlimit => { optional => 1 },
+ preallocation => { optional => 1 },
};
}
sub clone_image {
my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
- die "storage definintion has no path\n" if !$scfg->{path};
+ die "storage definition has no path\n" if !$scfg->{path};
my ($vtype, $basename, $basevmid, undef, undef, $isBase, $format) =
$class->parse_volname($volname);
mkpath $imagedir;
- my $name = $class->find_free_diskname($imagedir, $scfg, $vmid, "qcow2", 1);
+ my $name = $class->find_free_diskname($storeid, $scfg, $vmid, "qcow2", 1);
warn "clone $volname: $vtype, $name, $vmid to $name (base=../$basevmid/$basename)\n";
my $volumepath = "gluster://$server/$glustervolume/images/$vmid/$name";
my $cmd = ['/usr/bin/qemu-img', 'create', '-b', "../$basevmid/$basename",
- '-f', 'qcow2', $volumepath];
+ '-F', $format, '-f', 'qcow2', $volumepath];
run_command($cmd, errmsg => "unable to create image");
mkpath $imagedir;
- $name = $class->find_free_diskname($imagedir, $scfg, $vmid, $fmt, 1) if !$name;
+ $name = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt, 1) if !$name;
my (undef, $tmpfmt) = parse_name_dir($name);
my $cmd = ['/usr/bin/qemu-img', 'create'];
- push @$cmd, '-o', 'preallocation=metadata' if $fmt eq 'qcow2';
+ my $prealloc_opt = PVE::Storage::Plugin::preallocation_cmd_option($scfg, $fmt);
+ push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
push @$cmd, '-f', $fmt, $volumepath, "${size}K";