mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-07-09 11:02:53 +00:00
pending apply/hotplug: don't hard code force to true
Each pending options has a hash value which has the 'force' information encoded as entry. But, this can be { force => 1 } or { force => 0 }, so we actually need to check the value and not just set force to the hash directly, as else we have force always truthy.. fixes a bug where 'detach' caused disks to be destroyed immediately, because $force parameter was always true since hash is true. Signed-off-by: Oguz Bektas <o.bektas@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
6b4b369fe3
commit
fb4d1ba27e
@ -4856,7 +4856,8 @@ sub vmconfig_hotplug_pending {
|
|||||||
my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
|
my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
|
||||||
|
|
||||||
my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
|
my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
|
||||||
while (my ($opt, $force) = each %$pending_delete_hash) {
|
foreach my $opt (keys %$pending_delete_hash) {
|
||||||
|
my $force = $pending_delete_hash->{$opt}->{force};
|
||||||
next if $selection && !$selection->{$opt};
|
next if $selection && !$selection->{$opt};
|
||||||
eval {
|
eval {
|
||||||
if ($opt eq 'hotplug') {
|
if ($opt eq 'hotplug') {
|
||||||
@ -5054,8 +5055,9 @@ sub vmconfig_apply_pending {
|
|||||||
# cold plug
|
# cold plug
|
||||||
|
|
||||||
my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
|
my $pending_delete_hash = PVE::QemuConfig->parse_pending_delete($conf->{pending}->{delete});
|
||||||
while (my ($opt, $force) = each %$pending_delete_hash) {
|
foreach my $opt (keys %$pending_delete_hash) {
|
||||||
die "internal error" if $opt =~ m/^unused/;
|
die "internal error" if $opt =~ m/^unused/;
|
||||||
|
my $force = $pending_delete_hash->{$opt}->{force};
|
||||||
$conf = PVE::QemuConfig->load_config($vmid); # update/reload
|
$conf = PVE::QemuConfig->load_config($vmid); # update/reload
|
||||||
if (!defined($conf->{$opt})) {
|
if (!defined($conf->{$opt})) {
|
||||||
PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
|
PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
|
||||||
|
Loading…
Reference in New Issue
Block a user