From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id ECD031FF09C for ; Mon, 19 Oct 2026 16:49:03 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 49EB321881; Mon, 19 Oct 2026 16:47:03 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager v5 12/28] resources: add migrate_json_properties() method Date: Mon, 19 Oct 2026 16:45:54 +0200 Message-ID: <20261019144629.215541-13-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261019144629.215541-1-f.ebner@proxmox.com> References: <20261019144629.215541-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792421194131 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.365 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5DH4DK5FKRDTNIJVXOSTMAVQ6F5SINRL X-Message-ID-Hash: 5DH4DK5FKRDTNIJVXOSTMAVQ6F5SINRL X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Will be used by the API schema for resource-type specific migration options. When migrating dependent resources, the migration options will be filtered according to the resource type, so the property schema is also needed there. Signed-off-by: Fiona Ebner --- Dependency bump for pve-container and qemu-server needed! Changes in v5: * Add required include for PVE::Cluster already in this patch. * Only construct properties hash once. src/PVE/HA/Resources.pm | 21 +++++++++++++++++++++ src/PVE/HA/Resources/PVECT.pm | 17 +++++++++++++++++ src/PVE/HA/Resources/PVEVM.pm | 17 +++++++++++++++++ src/PVE/HA/Sim/Resources.pm | 6 ++++++ 4 files changed, 61 insertions(+) diff --git a/src/PVE/HA/Resources.pm b/src/PVE/HA/Resources.pm index 656cb19..ad603dc 100644 --- a/src/PVE/HA/Resources.pm +++ b/src/PVE/HA/Resources.pm @@ -3,6 +3,7 @@ package PVE::HA::Resources; use strict; use warnings; +use PVE::Cluster; use PVE::JSONSchema qw(get_standard_option); use PVE::SectionConfig; use PVE::HA::Tools; @@ -103,6 +104,20 @@ EODESC }, }; +our $common_migrate_json_properties = { + sid => get_standard_option( + 'pve-ha-resource-or-vm-id', + { completion => \&PVE::HA::Tools::complete_sid }, + ), + node => get_standard_option( + 'pve-node', + { + completion => \&PVE::Cluster::complete_migration_target, + description => "Target node.", + }, + ), +}; + sub verify_name { my ($class, $name) = @_; @@ -159,6 +174,12 @@ sub migrate { die "implement in subclass"; } +sub migrate_json_properties { + my ($class) = @_; + + die "implement in subclass"; +} + sub config_file { my ($class, $id, $nodename) = @_; diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index a8fe42e..de7c5b8 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -22,6 +22,17 @@ BEGIN { use base qw(PVE::HA::Resources); +my $ct_migrate_json_properties; +# FIXME: the extra properties are missing from the docs, since the PVE::API2::LXC module can't be +# included in the generating docs environment, because of cyclic dependencies.. +my sub init_migrate_json_properties { + my $combined = { $PVE::HA::Resources::common_migrate_json_properties->%* }; + my $extra_migrate_props = eval { PVE::API2::LXC::ha_migrate_json_properties() } // {}; + die $@ if $@ && !$ENV{PVE_GENERATING_DOCS}; + $combined->{$_} = $extra_migrate_props->{$_} for keys $extra_migrate_props->%*; + $ct_migrate_json_properties = $combined; +} + sub type { return 'ct'; } @@ -174,4 +185,10 @@ sub get_static_stats_from_config { }; } +sub migrate_json_properties { + my ($class) = @_; + init_migrate_json_properties() if !defined($ct_migrate_json_properties); + return $ct_migrate_json_properties +} + 1; diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index 3b61113..914f406 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -22,6 +22,17 @@ BEGIN { use base qw(PVE::HA::Resources); +my $vm_migrate_json_properties; +# FIXME: the extra properties are missing from the docs, since the PVE::API2::QEMU module can't be +# included in the generating docs environment, because of cyclic dependencies.. +my sub init_migrate_json_properties { + my $combined = { $PVE::HA::Resources::common_migrate_json_properties->%* }; + my $extra_migrate_props = eval { PVE::API2::Qemu::ha_migrate_json_properties() } // {}; + die $@ if $@ && !$ENV{PVE_GENERATING_DOCS}; + $combined->{$_} = $extra_migrate_props->{$_} for keys $extra_migrate_props->%*; + $vm_migrate_json_properties = $combined; +} + sub type { return 'vm'; } @@ -194,4 +205,10 @@ sub get_static_stats_from_config { }; } +sub migrate_json_properties { + my ($class) = @_; + init_migrate_json_properties() if !defined($vm_migrate_json_properties); + return $vm_migrate_json_properties; +} + 1; diff --git a/src/PVE/HA/Sim/Resources.pm b/src/PVE/HA/Sim/Resources.pm index a464c62..730bfaa 100644 --- a/src/PVE/HA/Sim/Resources.pm +++ b/src/PVE/HA/Sim/Resources.pm @@ -122,6 +122,12 @@ sub migrate { return defined($ss->{$sid}) ? 0 : 1; } +sub migrate_json_properties { + my ($class) = @_; + + return $PVE::HA::Resources::common_migrate_json_properties; +} + sub remove_locks { my ($self, $haenv, $id, $locks, $service_node) = @_; -- 2.47.3