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

Fabian Ebner f.ebner at proxmox.com
Wed Jul 1 13:39:05 CEST 2020


Allows to mock moving the configuration for testing
and reduces duplication between the migration modules by a tiny amount.

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

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

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

diff --git a/PVE/AbstractConfig.pm b/PVE/AbstractConfig.pm
index 4c9ad2c..b9228bb 100644
--- a/PVE/AbstractConfig.pm
+++ b/PVE/AbstractConfig.pm
@@ -274,6 +274,17 @@ 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