blockdev: move helper for resize into module
And replace the deprecated check_running() call while at it. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
384edceb02
commit
61efcc5556
3 changed files with 24 additions and 22 deletions
|
|
@ -28,6 +28,7 @@ use PVE::GuestImport;
|
|||
use PVE::QemuConfig;
|
||||
use PVE::QemuServer;
|
||||
use PVE::QemuServer::Agent;
|
||||
use PVE::QemuServer::Blockdev;
|
||||
use PVE::QemuServer::BlockJob;
|
||||
use PVE::QemuServer::Cloudinit;
|
||||
use PVE::QemuServer::CPUConfig;
|
||||
|
|
@ -5745,7 +5746,7 @@ __PACKAGE__->register_method({
|
|||
"update VM $vmid: resize --disk $disk --size $sizestr",
|
||||
);
|
||||
|
||||
PVE::QemuServer::qemu_block_resize(
|
||||
PVE::QemuServer::Blockdev::resize(
|
||||
$vmid, "drive-$disk", $storecfg, $volid, $newsize,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -4341,27 +4341,6 @@ sub qemu_block_set_io_throttle {
|
|||
|
||||
}
|
||||
|
||||
sub qemu_block_resize {
|
||||
my ($vmid, $deviceid, $storecfg, $volid, $size) = @_;
|
||||
|
||||
my $running = check_running($vmid);
|
||||
|
||||
PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
|
||||
|
||||
return if !$running;
|
||||
|
||||
my $padding = (1024 - $size % 1024) % 1024;
|
||||
$size = $size + $padding;
|
||||
|
||||
mon_cmd(
|
||||
$vmid,
|
||||
"block_resize",
|
||||
device => $deviceid,
|
||||
size => int($size),
|
||||
timeout => 60,
|
||||
);
|
||||
}
|
||||
|
||||
sub qemu_volume_snapshot {
|
||||
my ($vmid, $deviceid, $storecfg, $volid, $snap) = @_;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use PVE::JSONSchema qw(json_bool);
|
|||
use PVE::Storage;
|
||||
|
||||
use PVE::QemuServer::Drive qw(drive_is_cdrom);
|
||||
use PVE::QemuServer::Helpers;
|
||||
use PVE::QemuServer::Monitor qw(mon_cmd);
|
||||
|
||||
my sub tpm_backup_node_name {
|
||||
|
|
@ -499,4 +500,25 @@ sub detach_fleecing_block_nodes {
|
|||
}
|
||||
}
|
||||
|
||||
sub resize {
|
||||
my ($vmid, $deviceid, $storecfg, $volid, $size) = @_;
|
||||
|
||||
my $running = PVE::QemuServer::Helpers::vm_running_locally($vmid);
|
||||
|
||||
PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
|
||||
|
||||
return if !$running;
|
||||
|
||||
my $padding = (1024 - $size % 1024) % 1024;
|
||||
$size = $size + $padding;
|
||||
|
||||
mon_cmd(
|
||||
$vmid,
|
||||
"block_resize",
|
||||
device => $deviceid,
|
||||
size => int($size),
|
||||
timeout => 60,
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue