mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-29 15:24:32 +00:00
vmconfig_cleanup_pending: new method to clenup setting in [PENDING]
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
3d7389fe15
commit
c750e90abd
@ -1006,14 +1006,8 @@ my $update_vm_api = sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# remove pending changes when nothing changed
|
# remove pending changes when nothing changed
|
||||||
my $changes;
|
|
||||||
$conf = PVE::QemuServer::load_config($vmid); # update/reload
|
$conf = PVE::QemuServer::load_config($vmid); # update/reload
|
||||||
foreach my $opt (keys %{$conf->{pending}}) { # add/change
|
my $changes = PVE::QemuServer::vmconfig_cleanup_pending($conf);
|
||||||
if (defined($conf->{$opt}) && ($conf->{pending}->{$opt} eq $conf->{$opt})) {
|
|
||||||
$changes = 1;
|
|
||||||
delete $conf->{pending}->{$opt};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PVE::QemuServer::update_config_nolock($vmid, $conf, 1) if $changes;
|
PVE::QemuServer::update_config_nolock($vmid, $conf, 1) if $changes;
|
||||||
|
|
||||||
return if !scalar(keys %{$conf->{pending}});
|
return if !scalar(keys %{$conf->{pending}});
|
||||||
|
@ -1486,6 +1486,38 @@ sub vmconfig_register_unused_drive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub vmconfig_cleanup_pending {
|
||||||
|
my ($conf) = @_;
|
||||||
|
|
||||||
|
# remove pending changes when nothing changed
|
||||||
|
my $changes;
|
||||||
|
foreach my $opt (keys %{$conf->{pending}}) {
|
||||||
|
if (defined($conf->{$opt}) && ($conf->{pending}->{$opt} eq $conf->{$opt})) {
|
||||||
|
$changes = 1;
|
||||||
|
delete $conf->{pending}->{$opt};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove delete if option is not set
|
||||||
|
my $pending_delete_hash = {};
|
||||||
|
foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
|
||||||
|
if (defined($conf->{$opt})) {
|
||||||
|
$pending_delete_hash->{$opt} = 1;
|
||||||
|
} else {
|
||||||
|
$changes = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my @keylist = keys %$pending_delete_hash;
|
||||||
|
if (scalar(@keylist)) {
|
||||||
|
$conf->{pending}->{delete} = join(',', @keylist);
|
||||||
|
} else {
|
||||||
|
delete $conf->{pending}->{delete};
|
||||||
|
}
|
||||||
|
|
||||||
|
return $changes;
|
||||||
|
}
|
||||||
|
|
||||||
my $valid_smbios1_options = {
|
my $valid_smbios1_options = {
|
||||||
manufacturer => '\S+',
|
manufacturer => '\S+',
|
||||||
product => '\S+',
|
product => '\S+',
|
||||||
|
Loading…
Reference in New Issue
Block a user