plugin: add qemu_img_create
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
8099a4639f
commit
dd2bd851ca
@ -631,6 +631,29 @@ sub preallocation_cmd_option {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head3 qemu_img_create
|
||||||
|
|
||||||
|
qemu_img_create($scfg, $fmt, $size, $path)
|
||||||
|
|
||||||
|
Create a new qemu image with a specific format C<$format> and size C<$size> for a target C<$path>.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub qemu_img_create {
|
||||||
|
my ($scfg, $fmt, $size, $path) = @_;
|
||||||
|
|
||||||
|
my $cmd = ['/usr/bin/qemu-img', 'create'];
|
||||||
|
|
||||||
|
my $prealloc_opt = preallocation_cmd_option($scfg, $fmt);
|
||||||
|
push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
|
||||||
|
|
||||||
|
push @$cmd, '-f', $fmt, $path, "${size}K";
|
||||||
|
|
||||||
|
run_command($cmd, errmsg => "unable to create image");
|
||||||
|
}
|
||||||
|
|
||||||
# Storage implementation
|
# Storage implementation
|
||||||
|
|
||||||
# called during addition of storage (before the new storage config got written)
|
# called during addition of storage (before the new storage config got written)
|
||||||
@ -969,14 +992,7 @@ sub alloc_image {
|
|||||||
umask $old_umask;
|
umask $old_umask;
|
||||||
die $err if $err;
|
die $err if $err;
|
||||||
} else {
|
} else {
|
||||||
my $cmd = ['/usr/bin/qemu-img', 'create'];
|
eval { qemu_img_create($scfg, $fmt, $size, $path) };
|
||||||
|
|
||||||
my $prealloc_opt = preallocation_cmd_option($scfg, $fmt);
|
|
||||||
push @$cmd, '-o', $prealloc_opt if defined($prealloc_opt);
|
|
||||||
|
|
||||||
push @$cmd, '-f', $fmt, $path, "${size}K";
|
|
||||||
|
|
||||||
eval { run_command($cmd, errmsg => "unable to create image"); };
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
unlink $path;
|
unlink $path;
|
||||||
rmdir $imagedir;
|
rmdir $imagedir;
|
||||||
|
|||||||
Reference in New Issue
Block a user