mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-06 07:36:22 +00:00
Drop skiplock from write_config
Since write_config was always called with skiplock=1 except once, it makes sense to drop this parameter like in PVE::LXC::write_config . If needed in the future, the caller can use check_lock before write_config anyway.
This commit is contained in:
parent
63be43a947
commit
8317c759bf
@ -908,7 +908,7 @@ my $update_vm_api = sub {
|
||||
$rpcenv->check_vm_perm($authuser, $vmid, undef, ['VM.Config.Disk']);
|
||||
if (PVE::QemuServer::try_deallocate_drive($storecfg, $vmid, $conf, $opt, $drive, $rpcenv, $authuser)) {
|
||||
delete $conf->{$opt};
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
}
|
||||
} elsif (PVE::QemuServer::valid_drivename($opt)) {
|
||||
&$check_protection($conf, "can't remove drive '$opt'");
|
||||
@ -916,10 +916,10 @@ my $update_vm_api = sub {
|
||||
PVE::QemuServer::vmconfig_register_unused_drive($storecfg, $vmid, $conf, PVE::QemuServer::parse_drive($opt, $conf->{pending}->{$opt}))
|
||||
if defined($conf->{pending}->{$opt});
|
||||
PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force);
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
} else {
|
||||
PVE::QemuServer::vmconfig_delete_pending_option($conf, $opt, $force);
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -943,13 +943,13 @@ my $update_vm_api = sub {
|
||||
$conf->{pending}->{$opt} = $param->{$opt};
|
||||
}
|
||||
PVE::QemuServer::vmconfig_undelete_pending_option($conf, $opt);
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
}
|
||||
|
||||
# remove pending changes when nothing changed
|
||||
$conf = PVE::QemuServer::load_config($vmid); # update/reload
|
||||
my $changes = PVE::QemuServer::vmconfig_cleanup_pending($conf);
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1) if $changes;
|
||||
PVE::QemuServer::write_config($vmid, $conf) if $changes;
|
||||
|
||||
return if !scalar(keys %{$conf->{pending}});
|
||||
|
||||
@ -2292,11 +2292,11 @@ __PACKAGE__->register_method({
|
||||
|
||||
$newconf->{$opt} = PVE::QemuServer::print_drive($vmid, $newdrive);
|
||||
|
||||
PVE::QemuServer::write_config($newid, $newconf, 1);
|
||||
PVE::QemuServer::write_config($newid, $newconf);
|
||||
}
|
||||
|
||||
delete $newconf->{lock};
|
||||
PVE::QemuServer::write_config($newid, $newconf, 1);
|
||||
PVE::QemuServer::write_config($newid, $newconf);
|
||||
|
||||
if ($target) {
|
||||
# always deactivate volumes - avoid lvm LVs to be active on several nodes
|
||||
@ -2455,7 +2455,7 @@ __PACKAGE__->register_method({
|
||||
|
||||
PVE::QemuServer::add_unused_volume($conf, $old_volid) if !$param->{delete};
|
||||
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
|
||||
eval {
|
||||
# try to deactivate volumes - avoid lvm LVs to be active on several nodes
|
||||
@ -2477,7 +2477,7 @@ __PACKAGE__->register_method({
|
||||
if (PVE::QemuServer::is_volume_in_use($storecfg, $conf, undef, $old_volid)) {
|
||||
warn "volume $old_volid still has snapshots, can't delete it\n";
|
||||
PVE::QemuServer::add_unused_volume($conf, $old_volid);
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
} else {
|
||||
eval { PVE::Storage::vdisk_free($storecfg, $old_volid); };
|
||||
warn $@ if $@;
|
||||
@ -2748,7 +2748,7 @@ __PACKAGE__->register_method({
|
||||
$drive->{size} = $newsize;
|
||||
$conf->{$disk} = PVE::QemuServer::print_drive($vmid, $drive);
|
||||
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
};
|
||||
|
||||
PVE::QemuServer::lock_config($vmid, $updatefn);
|
||||
@ -2953,7 +2953,7 @@ __PACKAGE__->register_method({
|
||||
|
||||
$snap->{description} = $param->{description} if defined($param->{description});
|
||||
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
};
|
||||
|
||||
PVE::QemuServer::lock_config($vmid, $updatefn);
|
||||
@ -3149,7 +3149,7 @@ __PACKAGE__->register_method({
|
||||
};
|
||||
|
||||
$conf->{template} = 1;
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
|
||||
return $rpcenv->fork_worker('qmtemplate', $vmid, $authuser, $realcmd);
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ __PACKAGE__->register_method ({
|
||||
my $conf = PVE::QemuServer::load_config($vmid);
|
||||
delete $conf->{lock};
|
||||
delete $conf->{pending}->{lock} if $conf->{pending}; # just to be sure
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
});
|
||||
|
||||
return undef;
|
||||
|
@ -277,7 +277,7 @@ sub phase1 {
|
||||
|
||||
# set migrate lock in config file
|
||||
$conf->{lock} = 'migrate';
|
||||
PVE::QemuServer::write_config($vmid, $conf, 1);
|
||||
PVE::QemuServer::write_config($vmid, $conf);
|
||||
|
||||
sync_disks($self, $vmid);
|
||||
|
||||
@ -290,7 +290,7 @@ sub phase1_cleanup {
|
||||
|
||||
my $conf = $self->{vmconf};
|
||||
delete $conf->{lock};
|
||||
eval { PVE::QemuServer::write_config($vmid, $conf, 1) };
|
||||
eval { PVE::QemuServer::write_config($vmid, $conf) };
|
||||
if (my $err = $@) {
|
||||
$self->log('err', $err);
|
||||
}
|
||||
@ -546,7 +546,7 @@ sub phase2_cleanup {
|
||||
|
||||
my $conf = $self->{vmconf};
|
||||
delete $conf->{lock};
|
||||
eval { PVE::QemuServer::write_config($vmid, $conf, 1) };
|
||||
eval { PVE::QemuServer::write_config($vmid, $conf) };
|
||||
if (my $err = $@) {
|
||||
$self->log('err', $err);
|
||||
}
|
||||
|
@ -2245,9 +2245,7 @@ sub write_vm_config {
|
||||
}
|
||||
|
||||
sub write_config {
|
||||
my ($vmid, $conf, $skiplock) = @_;
|
||||
|
||||
check_lock($conf) if !$skiplock;
|
||||
my ($vmid, $conf) = @_;
|
||||
|
||||
my $cfspath = cfs_config_path($vmid);
|
||||
|
||||
@ -3213,7 +3211,7 @@ sub config_to_command {
|
||||
#if dimm_memory is not aligned to dimm map
|
||||
if($current_size > $memory) {
|
||||
$conf->{memory} = $current_size;
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -3870,7 +3868,7 @@ sub qemu_memory_hotplug {
|
||||
}
|
||||
#update conf after each succesful module hotplug
|
||||
$conf->{memory} = $current_size;
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -3895,7 +3893,7 @@ sub qemu_memory_hotplug {
|
||||
$conf->{memory} = $current_size;
|
||||
|
||||
eval { qemu_objectdel($vmid, "mem-$name"); };
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -4148,7 +4146,7 @@ sub vmconfig_hotplug_pending {
|
||||
}
|
||||
|
||||
if ($changes) {
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
$conf = load_config($vmid); # update/reload
|
||||
}
|
||||
|
||||
@ -4199,7 +4197,7 @@ sub vmconfig_hotplug_pending {
|
||||
# save new config if hotplug was successful
|
||||
delete $conf->{$opt};
|
||||
vmconfig_undelete_pending_option($conf, $opt);
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
$conf = load_config($vmid); # update/reload
|
||||
}
|
||||
}
|
||||
@ -4257,7 +4255,7 @@ sub vmconfig_hotplug_pending {
|
||||
# save new config if hotplug was successful
|
||||
$conf->{$opt} = $value;
|
||||
delete $conf->{pending}->{$opt};
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
$conf = load_config($vmid); # update/reload
|
||||
}
|
||||
}
|
||||
@ -4313,16 +4311,16 @@ sub vmconfig_apply_pending {
|
||||
$conf = load_config($vmid); # update/reload
|
||||
if (!defined($conf->{$opt})) {
|
||||
vmconfig_undelete_pending_option($conf, $opt);
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
} elsif (valid_drivename($opt)) {
|
||||
vmconfig_delete_or_detach_drive($vmid, $storecfg, $conf, $opt, $force);
|
||||
vmconfig_undelete_pending_option($conf, $opt);
|
||||
delete $conf->{$opt};
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
} else {
|
||||
vmconfig_undelete_pending_option($conf, $opt);
|
||||
delete $conf->{$opt};
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4342,7 +4340,7 @@ sub vmconfig_apply_pending {
|
||||
}
|
||||
|
||||
delete $conf->{pending}->{$opt};
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5422,7 +5420,7 @@ sub rescan {
|
||||
|
||||
my $changes = update_disksize($vmid, $conf, $vm_volids);
|
||||
|
||||
write_config($vmid, $conf, 1) if $changes;
|
||||
write_config($vmid, $conf) if $changes;
|
||||
};
|
||||
|
||||
if (defined($vmid)) {
|
||||
@ -5947,7 +5945,7 @@ my $snapshot_prepare = sub {
|
||||
# always overwrite machine if we save vmstate. This makes sure we
|
||||
# can restore it later using correct machine type
|
||||
$snap->{machine} = get_current_qemu_machine($vmid) if $snap->{vmstate};
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
};
|
||||
|
||||
lock_config($vmid, $updatefn);
|
||||
@ -5983,7 +5981,7 @@ my $snapshot_commit = sub {
|
||||
|
||||
$newconf->{parent} = $snapname;
|
||||
|
||||
write_config($vmid, $newconf, 1);
|
||||
write_config($vmid, $newconf);
|
||||
};
|
||||
|
||||
lock_config($vmid, $updatefn);
|
||||
@ -6062,7 +6060,7 @@ sub snapshot_rollback {
|
||||
delete $conf->{machine} if $snap->{vmstate} && !$has_machine_config;
|
||||
}
|
||||
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
|
||||
if (!$prepare && $snap->{vmstate}) {
|
||||
my $statefile = PVE::Storage::path($storecfg, $snap->{vmstate});
|
||||
@ -6270,7 +6268,7 @@ sub snapshot_delete {
|
||||
}
|
||||
}
|
||||
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
};
|
||||
|
||||
lock_config($vmid, $updatefn);
|
||||
@ -6348,7 +6346,7 @@ sub template_create {
|
||||
my $voliddst = PVE::Storage::vdisk_create_base($storecfg, $volid);
|
||||
$drive->{file} = $voliddst;
|
||||
$conf->{$ds} = print_drive($vmid, $drive);
|
||||
write_config($vmid, $conf, 1);
|
||||
write_config($vmid, $conf);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user