plugins: volume import: align size up to 1KiB
Previously, the size was rounded down which, in case of an image with non-1KiB-aligned sze (only possible for external plugins or manually created images) would lead to errors when attempting to write beyond the end of the too small allocated target image. For image allocation, the size is already rounded up to the granularity of the storage. Do the same for import. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
c41d7755c3
commit
a1140d77d0
@ -9,6 +9,8 @@ use PVE::Tools qw(run_command trim);
|
||||
use PVE::Storage::Plugin;
|
||||
use PVE::JSONSchema qw(get_standard_option);
|
||||
|
||||
use PVE::Storage::Common;
|
||||
|
||||
use base qw(PVE::Storage::Plugin);
|
||||
|
||||
# lvm helper functions
|
||||
@ -677,7 +679,7 @@ sub volume_import {
|
||||
}
|
||||
|
||||
my ($size) = PVE::Storage::Plugin::read_common_header($fh);
|
||||
$size = int($size/1024);
|
||||
$size = PVE::Storage::Common::align_size_up($size, 1024) / 1024;
|
||||
|
||||
eval {
|
||||
my $allocname = $class->alloc_image($storeid, $scfg, $vmid, 'raw', $name, $size);
|
||||
|
||||
@ -15,6 +15,8 @@ use PVE::Tools qw(run_command);
|
||||
use PVE::JSONSchema qw(get_standard_option register_standard_option);
|
||||
use PVE::Cluster qw(cfs_register_file);
|
||||
|
||||
use PVE::Storage::Common;
|
||||
|
||||
use JSON;
|
||||
|
||||
use base qw(PVE::SectionConfig);
|
||||
@ -1777,7 +1779,7 @@ sub volume_import {
|
||||
}
|
||||
|
||||
my ($size) = read_common_header($fh);
|
||||
$size = int($size/1024);
|
||||
$size = PVE::Storage::Common::align_size_up($size, 1024) / 1024;
|
||||
|
||||
eval {
|
||||
my $allocname = $class->alloc_image($storeid, $scfg, $vmid, $file_format, $name, $size);
|
||||
|
||||
@ -18,6 +18,8 @@ use PVE::RPCEnvironment;
|
||||
use PVE::Storage::Plugin;
|
||||
use PVE::Tools qw(run_command trim file_read_firstline);
|
||||
|
||||
use PVE::Storage::Common;
|
||||
|
||||
use base qw(PVE::Storage::Plugin);
|
||||
|
||||
my $get_parent_image_name = sub {
|
||||
@ -955,7 +957,7 @@ sub volume_import {
|
||||
}
|
||||
|
||||
my ($size) = PVE::Storage::Plugin::read_common_header($fh);
|
||||
$size = int($size/1024);
|
||||
$size = PVE::Storage::Common::align_size_up($size, 1024) / 1024;
|
||||
|
||||
eval {
|
||||
my $cmd = $rbd_cmd->($scfg, $storeid, 'import', '--export-format', '1', '-', $volname);
|
||||
|
||||
Reference in New Issue
Block a user