From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource
Date: Mon, 10 Nov 2025 15:36:17 +0100 [thread overview]
Message-ID: <20251110143627.365434-3-d.kral@proxmox.com> (raw)
In-Reply-To: <20251110143627.365434-1-d.kral@proxmox.com>
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 <d.kral@proxmox.com>
---
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
next prev parent reply other threads:[~2025-11-10 14:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 14:36 [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH ha-manager 1/1] api: resources: fix uninitialized value in check_service_state Daniel Kral
2025-11-10 14:36 ` Daniel Kral [this message]
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 2/3] qmrestore: allow starting a VM after it was restored successfully Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 3/3] qmrestore: allow adding a VM as an HA resource after it was restored Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH container 1/1] api: create_vm: use ha-manager command to add container as an HA resource Daniel Kral
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251110143627.365434-3-d.kral@proxmox.com \
--to=d.kral@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox