From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A4ADB1FF17A for ; Fri, 4 Jul 2025 20:22:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3F36F3DE15; Fri, 4 Jul 2025 20:21:49 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Fri, 4 Jul 2025 20:21:02 +0200 Message-Id: <20250704182102.467624-20-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250704182102.467624-1-d.kral@proxmox.com> References: <20250704182102.467624-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v3 1/1] api: migration preconditions: add checks for ha resource affinity rules X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Add information about positive and negative ha resource affinity rules, which the VM is part of, to the migration precondition API endpoint. These inform callees about any comigrated resources or blocking resources that are caused by the resource affinity rules. Signed-off-by: Daniel Kral --- src/PVE/API2/Qemu.pm | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 2e6358e4..8a122cfb 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -5094,6 +5094,28 @@ __PACKAGE__->register_method({ description => 'A storage', }, }, + 'blocking-ha-resources' => { + description => "HA resources, which are blocking the" + . " VM from being migrated to the node.", + type => 'array', + optional => 1, + items => { + description => "A blocking HA resource", + type => 'object', + properties => { + sid => { + type => 'string', + description => "The blocking HA resource id", + }, + cause => { + type => 'string', + description => "The reason why the HA" + . " resource is blocking the migration.", + enum => ['resource-affinity'], + }, + }, + }, + }, }, description => "List of not allowed nodes with additional information.", }, @@ -5146,6 +5168,17 @@ __PACKAGE__->register_method({ description => "Object of mapped resources with additional information such if they're live migratable.", }, + 'comigrated-ha-resources' => { + description => "HA resources, which will be migrated to the" + . " same target node as the VM, because these are in" + . " positive affinity with the VM.", + type => 'array', + optional => 1, + items => { + type => 'string', + description => "A comigrated HA resource", + }, + }, }, }, code => sub { @@ -5186,6 +5219,14 @@ __PACKAGE__->register_method({ my $storage_nodehash = PVE::QemuServer::check_local_storage_availability($vmconf, $storecfg); + my $comigrated_ha_resources = {}; + my $blocking_ha_resources_by_node = {}; + + if (PVE::HA::Config::vm_is_ha_managed($vmid)) { + ($comigrated_ha_resources, $blocking_ha_resources_by_node) = + PVE::HA::Config::get_resource_motion_info("vm:$vmid"); + } + my $nodelist = PVE::Cluster::get_nodelist(); for my $node ($nodelist->@*) { next if $node eq $localnode; @@ -5202,6 +5243,12 @@ __PACKAGE__->register_method({ $missing_mappings; } + # extracting blocking resources for current node + if (my $blocking_ha_resources = $blocking_ha_resources_by_node->{$node}) { + $res->{not_allowed_nodes}->{$node}->{'blocking-ha-resources'} = + $blocking_ha_resources; + } + # if nothing came up, add it to the allowed nodes if (scalar($res->{not_allowed_nodes}->{$node}->%*) == 0) { push $res->{allowed_nodes}->@*, $node; @@ -5215,6 +5262,8 @@ __PACKAGE__->register_method({ $res->{'mapped-resources'} = [sort keys $mapped_resources->%*]; $res->{'mapped-resource-info'} = $mapped_resources; + $res->{'comigrated-ha-resources'} = $comigrated_ha_resources; + return $res; }, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel