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 EC4311FF15E for ; Mon, 10 Nov 2025 15:35:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0DB63189E1; Mon, 10 Nov 2025 15:36:34 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Mon, 10 Nov 2025 15:36:17 +0100 Message-ID: <20251110143627.365434-3-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251110143627.365434-1-d.kral@proxmox.com> References: <20251110143627.365434-1-d.kral@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762785368201 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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 1/3] api: create_vm: use ha-manager command to add VM as an HA resource 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" PVE::API2::HA::Resources is not imported through a use statement here, so `qm create ... --ha-managed 1` will not add the VM as an HA resource. Replace the direct API call with a 'ha-manager' invocation as we don't seem to import API modules from other packages except in pve-manager and use the 'ha-manager' command at other call sites already. Signed-off-by: Daniel Kral --- src/PVE/API2/Qemu.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 71bedc1e..d7455275 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -1391,9 +1391,8 @@ __PACKAGE__->register_method({ if ($ha_managed) { print "Add as HA resource\n"; my $state = $start_after_create ? 'started' : 'stopped'; - eval { - PVE::API2::HA::Resources->create({ sid => "vm:$vmid", state => $state }); - }; + my $cmd = ['ha-manager', 'add', "vm:$vmid", '--state', $state]; + eval { PVE::Tools::run_command($cmd); }; warn $@ if $@; } }; @@ -1482,9 +1481,8 @@ __PACKAGE__->register_method({ if ($ha_managed) { print "Add as HA resource\n"; my $state = $start_after_create ? 'started' : 'stopped'; - eval { - PVE::API2::HA::Resources->create({ sid => "vm:$vmid", state => $state }); - }; + my $cmd = ['ha-manager', 'add', "vm:$vmid", '--state', $state]; + eval { PVE::Tools::run_command($cmd); }; warn $@ if $@; } -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel