--- Begin Message ---
After a virtual machine is destroyed, record that its ID has been used
via the `PVE::UsedVmidList` module so that the `/cluster/nextids`
endpoint can later optionally avoid suggesting previously used IDs.

Co-authored-by: Daniel Krambrock <krambr...@hrz.uni-marburg.de>
Signed-off-by: Severen Redwood <severen.redw...@sitehost.co.nz>
Tested-by: Aaron Lauterer <a.laute...@proxmox.com>
Reviewed-by: Aaron Lauterer <a.laute...@proxmox.com>
---
Changed since v3 is removing an unnecessary `qw(add_vmid)` after
`use PVE::UsedVmidList`.

 PVE/API2/Qemu.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 848001b6..22bc58d6 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -52,6 +52,7 @@ use PVE::Replication;
 use PVE::ReplicationState;
 use PVE::StorageTunnel;
 use PVE::RESTEnvironment qw(log_warn);
+use PVE::UsedVmidList;
 
 BEGIN {
     if (!$ENV{PVE_GENERATING_DOCS}) {
@@ -2335,7 +2336,9 @@ __PACKAGE__->register_method({
                    }
                }
 
-               # only now remove the zombie config, else we can have reuse race
+               # only now mark the VM ID as previously used and remove the
+               # zombie config, else we can have reuse race
+               PVE::UsedVmidList::add_vmid($vmid);
                PVE::QemuConfig->destroy_config($vmid);
            });
        };
-- 
2.47.0



--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to