mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-07-02 00:12:38 +00:00
fix for resize: only allow to resize one disk.
This commit is contained in:
parent
3b2773f606
commit
2f48a4f522
@ -452,6 +452,7 @@ __PACKAGE__->register_method({
|
|||||||
{ subdir => 'unlink' },
|
{ subdir => 'unlink' },
|
||||||
{ subdir => 'vncproxy' },
|
{ subdir => 'vncproxy' },
|
||||||
{ subdir => 'migrate' },
|
{ subdir => 'migrate' },
|
||||||
|
{ subdir => 'resize' },
|
||||||
{ subdir => 'rrd' },
|
{ subdir => 'rrd' },
|
||||||
{ subdir => 'rrddata' },
|
{ subdir => 'rrddata' },
|
||||||
{ subdir => 'monitor' },
|
{ subdir => 'monitor' },
|
||||||
@ -729,7 +730,7 @@ my $vmconfig_update_disk = sub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
my $vmconfig_resize_disk = sub {
|
my $vmconfig_resize_disk = sub {
|
||||||
my ($rpcenv, $authuser, $conf, $storecfg, $vmid, $opt, $value, $force) = @_;
|
my ($rpcenv, $authuser, $conf, $storecfg, $vmid, $opt, $value) = @_;
|
||||||
|
|
||||||
my $drive = PVE::QemuServer::parse_drive($opt, $value);
|
my $drive = PVE::QemuServer::parse_drive($opt, $value);
|
||||||
|
|
||||||
@ -1794,24 +1795,33 @@ __PACKAGE__->register_method({
|
|||||||
method => 'PUT',
|
method => 'PUT',
|
||||||
protected => 1,
|
protected => 1,
|
||||||
proxyto => 'node',
|
proxyto => 'node',
|
||||||
description => "extend volume size.",
|
description => "Extend volume size.",
|
||||||
permissions => {
|
permissions => {
|
||||||
check => ['perm', '/vms/{vmid}', [ 'VM.Config.Disk' ]],
|
check => ['perm', '/vms/{vmid}', [ 'VM.Config.Disk' ]],
|
||||||
},
|
},
|
||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => PVE::QemuServer::json_config_properties(
|
properties => {
|
||||||
{
|
node => get_standard_option('pve-node'),
|
||||||
node => get_standard_option('pve-node'),
|
vmid => get_standard_option('pve-vmid'),
|
||||||
vmid => get_standard_option('pve-vmid'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
skiplock => get_standard_option('skiplock'),
|
disk => {
|
||||||
digest => {
|
type => 'string',
|
||||||
type => 'string',
|
description => "The disk you want to resize.",
|
||||||
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
|
enum => [PVE::QemuServer::disknames()],
|
||||||
maxLength => 40,
|
},
|
||||||
optional => 1,
|
size => {
|
||||||
}
|
type => 'string',
|
||||||
}),
|
pattern => '[+]?\d+(\.\d+)?[KMGT]?',
|
||||||
|
description => "The new size. With the '+' sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.",
|
||||||
|
},
|
||||||
|
digest => {
|
||||||
|
type => 'string',
|
||||||
|
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
|
||||||
|
maxLength => 40,
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
returns => { type => 'null'},
|
returns => { type => 'null'},
|
||||||
code => sub {
|
code => sub {
|
||||||
@ -1827,24 +1837,17 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $digest = extract_param($param, 'digest');
|
my $digest = extract_param($param, 'digest');
|
||||||
|
|
||||||
my @paramarr = (); # used for log message
|
my $disk = extract_param($param, 'disk');
|
||||||
foreach my $key (keys %$param) {
|
|
||||||
push @paramarr, "-$key", $param->{$key};
|
my $sizestr = extract_param($param, 'size');
|
||||||
}
|
|
||||||
|
|
||||||
my $skiplock = extract_param($param, 'skiplock');
|
my $skiplock = extract_param($param, 'skiplock');
|
||||||
raise_param_exc({ skiplock => "Only root may use this option." })
|
raise_param_exc({ skiplock => "Only root may use this option." })
|
||||||
if $skiplock && $authuser ne 'root@pam';
|
if $skiplock && $authuser ne 'root@pam';
|
||||||
|
|
||||||
my $force = extract_param($param, 'force');
|
|
||||||
|
|
||||||
die "no options specified\n" if !scalar(keys %$param);
|
|
||||||
|
|
||||||
my $storecfg = PVE::Storage::config();
|
my $storecfg = PVE::Storage::config();
|
||||||
|
|
||||||
|
|
||||||
&$check_vm_modify_config_perm($rpcenv, $authuser, $vmid, undef, [keys %$param]);
|
|
||||||
|
|
||||||
&$check_storage_access($rpcenv, $authuser, $storecfg, $vmid, $param);
|
&$check_storage_access($rpcenv, $authuser, $storecfg, $vmid, $param);
|
||||||
|
|
||||||
my $updatefn = sub {
|
my $updatefn = sub {
|
||||||
@ -1855,14 +1858,9 @@ __PACKAGE__->register_method({
|
|||||||
if $digest && $digest ne $conf->{digest};
|
if $digest && $digest ne $conf->{digest};
|
||||||
PVE::QemuServer::check_lock($conf) if !$skiplock;
|
PVE::QemuServer::check_lock($conf) if !$skiplock;
|
||||||
|
|
||||||
PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: " . join (' ', @paramarr));
|
PVE::Cluster::log_msg('info', $authuser, "update VM $vmid: resize --disk $disk --size $sizestr");
|
||||||
|
|
||||||
foreach my $opt (keys %$param) { # add/change
|
|
||||||
if (PVE::QemuServer::valid_drivename($opt)) {
|
|
||||||
&$vmconfig_resize_disk($rpcenv, $authuser, $conf, $storecfg, $vmid, $opt, $param->{$opt}, $force);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
&$vmconfig_resize_disk($rpcenv, $authuser, $conf, $storecfg, $vmid, $disk, $sizestr);
|
||||||
};
|
};
|
||||||
|
|
||||||
PVE::QemuServer::lock_config($vmid, $updatefn);
|
PVE::QemuServer::lock_config($vmid, $updatefn);
|
||||||
|
2
qm
2
qm
@ -332,7 +332,7 @@ my $cmddef = {
|
|||||||
|
|
||||||
set => [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node => $nodename } ],
|
set => [ "PVE::API2::Qemu", 'update_vm', ['vmid'], { node => $nodename } ],
|
||||||
|
|
||||||
resize => [ "PVE::API2::Qemu", 'resize_vm', ['vmid'], { node => $nodename } ],
|
resize => [ "PVE::API2::Qemu", 'resize_vm', ['vmid', 'disk', 'size'], { node => $nodename } ],
|
||||||
|
|
||||||
unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid', 'idlist'], { node => $nodename } ],
|
unlink => [ "PVE::API2::Qemu", 'unlink', ['vmid', 'idlist'], { node => $nodename } ],
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user