[PATCH SERIES] Add ability to prevent suggesting previously used VM/CT IDs

Severen Redwood severen.redwood at sitehost.co.nz
Thu Sep 26 15:52:27 CEST 2024


Hi everyone,

This patch series is a reworking of Daniel Krambrock's patches [1] which
allow for configuring the strategy used for suggesting VM IDs. As
discussed with him [2], I have removed the 'max + 1' strategy as it is
fundamentally flawed given that the goal is preventing re-use of IDs
that can cause issues like #4369 [3]. This leaves two strategies, namely
the current behaviour of suggesting the lowest free ID and the new
optional behaviour of suggesting the lowest free *and* not previously
used ID. Beyond this, I have also fixed a bug where IDs would be
recorded as used multiple times and removed sorting the stored list of
IDs on write as it is not required.

I believe that the comments from Shannon Sterz relating to code style
should now be addressed, though there is still their comment on tracking
the used IDs in `/etc/pve/used_vmids.list`:

> Not sure if tracking the used VM/CT IDs in a separate file is the most
> elegant solution here. Especially as this is a somewhat niche usecase.

If this needs to be changed, then where should it go? I am not familiar
enough with the codebase to know what the preference would be. Note that
we *must* store a list of used IDs rather than a simple counter because
PVE allows you to choose any free ID you wish when creating a VM or
container.

As I re-wrote the commit messages and it felt strange to ghost-write
messages under someone else's name, the commit author on all patches is
myself with Daniel listed as a co-author using `Co-authored-by` trailers
in the commit message bodies. Please let me know if this isn't the right
convention :)

I have also sent in a signed CLA to cover my contributions.

Thanks,
Severen

[1]: https://lore.proxmox.com/pve-devel/D1RYIAHXBOIH.RM5K01KGND9T@proxmox.com/t/
[2]: https://lore.proxmox.com/pve-devel/mailman.472.1724973432.302.pve-devel@lists.proxmox.com/T/#u
[3]: https://bugzilla.proxmox.com/show_bug.cgi?id=4369#c13

pve-manager
-----------
Severen Redwood (2):
  close #4369: api: optionally only suggest unique
  close #4369: ui: add datacenter option for unique

 PVE/API2/Cluster.pm           | 12 ++++++--
 PVE/Makefile                  |  1 +
 PVE/UsedVmidList.pm           | 55 +++++++++++++++++++++++++++++++++++
 www/manager6/dc/OptionView.js |  4 +++
 4 files changed, 70 insertions(+), 2 deletions(-)
 create mode 100644 PVE/UsedVmidList.pm

pve-container
-------------
Severen Redwood (1):
  api: record CT ID as used after a container is destroyed

 src/PVE/API2/LXC.pm | 1 +
 1 file changed, 1 insertion(+)

qemu-server
-----------
Severen Redwood (1):
  api: record VM ID as used after a virtual machine is destroyed

 PVE/API2/Qemu.pm | 1 +
 1 file changed, 1 insertion(+)

pve-cluster
-----------
Severen Redwood (2):
  cluster files: add used_vmids.list
  datacenter config: add unique-next-id to schema

 src/PVE/Cluster.pm          | 1 +
 src/PVE/DataCenterConfig.pm | 5 +++++
 src/pmxcfs/status.c         | 1 +
 3 files changed, 7 insertions(+)




More information about the pve-devel mailing list