]> git.proxmox.com Git - qemu-server.git/commitdiff
Drop skiplock from write_config
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 12 Feb 2016 10:14:41 +0000 (11:14 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 12 Feb 2016 11:16:57 +0000 (12:16 +0100)
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.

PVE/API2/Qemu.pm
PVE/CLI/qm.pm
PVE/QemuMigrate.pm
PVE/QemuServer.pm

index c21287c389c2aaca87d7642329637a0bff68d557..226e597d899b6ea0d83b14439f9eb32e477b1585 100644 (file)
@@ -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);
        };
index 9a8f83954d1ac8e4a5a670b8728d7d793bbf5b2f..fdac3d570070b03da25f2cd02d51c5d438b311df 100755 (executable)
@@ -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;
index 5cacb51f2e4ce25872624d3a7d763749e0029aa1..973b6eefa4ce44fee0071e718fc6222329314a20 100644 (file)
@@ -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);
     }
index 9dd47779f45cde73d6c1cd080c92561660e167e4..1139438c77a41e7a1ec84f9eee0a1d4fdd95a804 100644 (file)
@@ -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);
     });
 }