[pve-devel] [PATCH v2 guest-common 1/5] Add move_config_to_node method

Fabian Ebner f.ebner at proxmox.com
Thu Aug 20 11:11:38 CEST 2020


allows to mock it when testing and a few lines less duplication
between the migration modules.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

Dependency bumps
{qemu-server,container} -> guest-common
are needed.

Changes from v1:
    * collect patches into one series
    * many new tests and improvements to the test modules, see last patch

 PVE/AbstractConfig.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index 4c9ad2c..5d1b662 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -274,6 +274,18 @@ sub destroy_config {
     unlink $config_fn or die "failed to remove config file: $!\n";
 }
 
+# moves configuration owned by calling node to the target node.
+# dies if renaming fails.
+sub move_config_to_node {
+    my ($class, $vmid, $target_node) = @_;
+
+    my $config_fn = $class->config_file($vmid);
+    my $new_config_fn = $class->config_file($vmid, $target_node);
+
+    rename($config_fn, $new_config_fn)
+	or die "failed to move config file to node '$target_node': $!\n";
+}
+
 my $lock_file_full_wrapper = sub {
     my ($class, $vmid, $timeout, $shared, $realcode, @param) = @_;
 
-- 
2.20.1






More information about the pve-devel mailing list