[pve-devel] [PATCH qemu-server v3] api: record VM ID as used after a virtual machine is destroyed
Aaron Lauterer
a.lauterer at proxmox.com
Tue Nov 5 16:50:01 CET 2024
beside one small nit that could be cleaned up in a follow-up,
consider this:
Tested-By: Aaron Lauterer <a.lauterer at proxmox.com>
Reviewed-By: Aaron Lauterer <a.lauterer at proxmox.com>
On 2024-11-05 03:00, Severen Redwood wrote:
> 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 <krambrock at hrz.uni-marburg.de>
> Signed-off-by: Severen Redwood <severen.redwood at sitehost.co.nz>
> ---
> Changed since v2 is the addition of the use statement for `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..8759c1e6 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 qw(add_vmid);
same here as in the container, we could probably do without the qw(add_vmid)
>
> 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);
> });
> };
More information about the pve-devel
mailing list