[pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource
Daniel Kral
d.kral at proxmox.com
Mon Nov 10 15:36:17 CET 2025
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 at 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
More information about the pve-devel
mailing list