* [pve-devel] [PATCH qemu-server v2 1/2] create_vm: assume HA state 'started' when live-restoring guests
2025-11-27 15:40 [pve-devel] [PATCH qemu-server v2 0/2] correctly set HA state then Michael Köppl
@ 2025-11-27 15:40 ` Michael Köppl
2025-11-27 15:40 ` [pve-devel] [PATCH qemu-server v2 2/2] create_vm: set HA state when restoring VM if resource already exists Michael Köppl
2025-11-29 22:49 ` [pve-devel] applied: [PATCH qemu-server v2 0/2] correctly set HA state then Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Michael Köppl @ 2025-11-27 15:40 UTC (permalink / raw)
To: pve-devel
To avoid shutting down the VM when performing a live-restore, consider
live-restore=1 to translate to a HA state of 'started', similar to
start=1.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/API2/Qemu.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index c580bf63..25b6529c 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -1418,7 +1418,7 @@ __PACKAGE__->register_method({
if ($ha_managed) {
print "Add as HA resource\n";
- my $state = $start_after_create ? 'started' : 'stopped';
+ my $state = $start_after_create || $live_restore ? 'started' : 'stopped';
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] 4+ messages in thread* [pve-devel] [PATCH qemu-server v2 2/2] create_vm: set HA state when restoring VM if resource already exists
2025-11-27 15:40 [pve-devel] [PATCH qemu-server v2 0/2] correctly set HA state then Michael Köppl
2025-11-27 15:40 ` [pve-devel] [PATCH qemu-server v2 1/2] create_vm: assume HA state 'started' when live-restoring guests Michael Köppl
@ 2025-11-27 15:40 ` Michael Köppl
2025-11-29 22:49 ` [pve-devel] applied: [PATCH qemu-server v2 0/2] correctly set HA state then Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Michael Köppl @ 2025-11-27 15:40 UTC (permalink / raw)
To: pve-devel
Instead of trying to add a HA resource in any case, which fails if it
already exists and will then not overwrite the status, check if the VM
already is a HA resource. If the resource already exists, set the status
of the existing resource, otherwise add the resource as before.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/API2/Qemu.pm | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 25b6529c..4d4f0873 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -1417,9 +1417,17 @@ __PACKAGE__->register_method({
}
if ($ha_managed) {
- print "Add as HA resource\n";
+ my $resource_exists = PVE::HA::Config::service_is_configured("vm:$vmid");
my $state = $start_after_create || $live_restore ? 'started' : 'stopped';
- my $cmd = ['ha-manager', 'add', "vm:$vmid", '--state', $state];
+ my $cmd;
+ if ($resource_exists) {
+ print "Update state of HA resource\n";
+ $cmd = ['ha-manager', 'set', "vm:$vmid", '--state', $state];
+ } else {
+ print "Add as HA resource\n";
+ $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] 4+ messages in thread* [pve-devel] applied: [PATCH qemu-server v2 0/2] correctly set HA state then
2025-11-27 15:40 [pve-devel] [PATCH qemu-server v2 0/2] correctly set HA state then Michael Köppl
2025-11-27 15:40 ` [pve-devel] [PATCH qemu-server v2 1/2] create_vm: assume HA state 'started' when live-restoring guests Michael Köppl
2025-11-27 15:40 ` [pve-devel] [PATCH qemu-server v2 2/2] create_vm: set HA state when restoring VM if resource already exists Michael Köppl
@ 2025-11-29 22:49 ` Thomas Lamprecht
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2025-11-29 22:49 UTC (permalink / raw)
To: pve-devel, Michael Köppl
On Thu, 27 Nov 2025 16:40:39 +0100, Michael Köppl wrote:
> This series makes 2 changes to the restore functionality for VMs:
> - Correctly set the HA state to 'started' for HA-managed VMs that are
> live-restored, since live-restore already implies start-after-create
> and otherwise the VM is shut down during restore.
> - When restoring VMs that already are HA resources, set the status of
> the existing resource instead of trying to add a new HA resource,
> which would fail and keep the old state of the existing resource.
>
> [...]
Applied, thanks!
[1/2] create_vm: assume HA state 'started' when live-restoring guests
commit: f9298ec1e1b14f4fc78b520d4c9e15c23c5f4516
[2/2] create_vm: set HA state when restoring VM if resource already exists
commit: 8546fe50039cf976062bd013107f5e09e172c95d
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread