* [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements
@ 2025-11-10 14:36 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
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: pve-devel
Some small fixes and improvements while playing around with the
HA-on-create feature related mainly to the CLI usage. Two qemu-server
patches only enhance the usage by allowing --ha-managed and --start
parameters for qmrestore.
pve-ha-manager.git:
Daniel Kral (1):
api: resources: fix uninitialized value in check_service_state
src/PVE/API2/HA/Resources.pm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
qemu-server.git:
Daniel Kral (3):
api: create_vm: use ha-manager command to add VM as an HA resource
qmrestore: allow starting a VM after it was restored successfully
qmrestore: allow adding a VM as an HA resource after it was restored
src/PVE/API2/Qemu.pm | 10 ++++------
src/PVE/CLI/qmrestore.pm | 12 ++++++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
pve-container.git:
Daniel Kral (1):
api: create_vm: use ha-manager command to add container as an HA
resource
src/PVE/API2/LXC.pm | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Summary over all repositories:
4 files changed, 22 insertions(+), 10 deletions(-)
--
Generated by git-murpp 0.8.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH ha-manager 1/1] api: resources: fix uninitialized value in check_service_state
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 ` Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource Daniel Kral
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: pve-devel
check_service_state(...) calls get_service_status(...), which assumes
that a configured HA resource is already present in the manager status.
If a HA resource is added to the configuration file and interacted with
such that check_service_state(...) is called before the HA Manager loads
the new HA resource in its state, then $service_status->{state} will be
undefined.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/API2/HA/Resources.pm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index acdd4992..9d3460e5 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -38,7 +38,11 @@ sub check_service_state {
my ($sid, $req_state) = @_;
my $service_status = PVE::HA::Config::get_service_status($sid);
- if ($service_status->{managed} && $service_status->{state} eq 'error') {
+ if (
+ $service_status->{managed}
+ && $service_status->{state}
+ && $service_status->{state} eq 'error'
+ ) {
# service in error state, must get disabled before new state request
# can be executed
return if defined($req_state) && $req_state eq 'disabled';
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource
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
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 2/3] qmrestore: allow starting a VM after it was restored successfully Daniel Kral
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: 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 <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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH qemu-server 2/3] qmrestore: allow starting a VM after it was restored successfully
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 ` [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource Daniel Kral
@ 2025-11-10 14:36 ` 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
4 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/CLI/qmrestore.pm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/PVE/CLI/qmrestore.pm b/src/PVE/CLI/qmrestore.pm
index 0153db57..ebe6665d 100755
--- a/src/PVE/CLI/qmrestore.pm
+++ b/src/PVE/CLI/qmrestore.pm
@@ -72,6 +72,12 @@ __PACKAGE__->register_method({
description =>
"Start the VM immediately from the backup and restore in background. PBS only.",
},
+ start => {
+ optional => 1,
+ type => 'boolean',
+ default => 0,
+ description => "Start VM after it was restored successfully.",
+ },
},
},
returns => {
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH qemu-server 3/3] qmrestore: allow adding a VM as an HA resource after it was restored
2025-11-10 14:36 [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements Daniel Kral
` (2 preceding siblings ...)
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 ` 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
4 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/CLI/qmrestore.pm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/PVE/CLI/qmrestore.pm b/src/PVE/CLI/qmrestore.pm
index ebe6665d..abfa2de7 100755
--- a/src/PVE/CLI/qmrestore.pm
+++ b/src/PVE/CLI/qmrestore.pm
@@ -78,6 +78,12 @@ __PACKAGE__->register_method({
default => 0,
description => "Start VM after it was restored successfully.",
},
+ 'ha-managed' => {
+ optional => 1,
+ type => 'boolean',
+ default => 0,
+ description => "Add the VM as a HA resource after it was restored.",
+ },
},
},
returns => {
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH container 1/1] api: create_vm: use ha-manager command to add container as an HA resource
2025-11-10 14:36 [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements Daniel Kral
` (3 preceding siblings ...)
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 ` Daniel Kral
4 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2025-11-10 14:36 UTC (permalink / raw)
To: pve-devel
PVE::API2::HA::Resources is not imported through a use statement here,
so `pct create ... --ha-managed 1` will not add the container 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/LXC.pm | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index e53b388..b792930 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -627,9 +627,7 @@ __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 => "ct:$vmid", state => $state });
- };
+ eval { run_command(['ha-manager', 'add', "ct:$vmid", '--state', $state]); };
warn $@ if $@;
}
};
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-10 14:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource Daniel Kral
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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.