[PR #4292] [MERGED] Feature: get correct next VMID #4791

Closed
opened 2026-02-26 14:32:05 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/community-scripts/ProxmoxVE/pull/4292
Author: @MickLesk
Created: 5/7/2025
Status: Merged
Merged: 5/7/2025
Merged by: @tremor021

Base: mainHead: vm_nextid_feature


📝 Commits (1)

  • 44c3549 Feature: get correct next VMID

📊 Changes

13 files changed (+270 additions, -60 deletions)

View changed files

📝 vm/archlinux-vm.sh (+21 -4)
📝 vm/debian-vm.sh (+21 -4)
📝 vm/docker-vm.sh (+21 -5)
📝 vm/haos-vm.sh (+22 -6)
📝 vm/mikrotik-routeros.sh (+18 -3)
📝 vm/nextcloud-vm.sh (+21 -6)
📝 vm/openwrt.sh (+21 -5)
📝 vm/opnsense-vm.sh (+22 -4)
📝 vm/owncloud-vm.sh (+22 -6)
📝 vm/pimox-haos-vm.sh (+18 -3)
📝 vm/ubuntu2204-vm.sh (+21 -6)
📝 vm/ubuntu2404-vm.sh (+21 -4)
📝 vm/ubuntu2410-vm.sh (+21 -4)

📄 Description

✍️ Description

This PR improves the robustness and usability of the VM creation workflow:

  • Introduces get_valid_nextid(), a helper function to find the next truly available VMID by checking:
    • /etc/pve/qemu-server/<id>.conf
    • /etc/pve/lxc/<id>.conf
    • orphaned LVM volumes via lvs
  • Ensures that the whiptail inputbox for "Virtual Machine ID" is always pre-filled with a valid and unused ID.
  • Fixes the issue where the input field was empty when $VMID was not explicitly set beforehand.
  • Removes reliance on pvesh get /cluster/nextid alone, which may suggest IDs that are technically blocked by orphaned resources.

Benefits

  • Prevents script crashes caused by pvesm alloc failing on orphaned volumes.
  • Improves UX in interactive shell scripts (especially when run via SSH or Proxmox GUI).
  • Ensures reproducibility and automation safety when the script is reused or extended.

Before (Docker-VM without the function):
image

After (Debian-VM with the new function) – set ID to 108 instead of 107):
image

Link: #4289

Prerequisites (X in brackets)

  • Self-review completed – Code follows project standards.
  • Tested thoroughly – Changes work as expected.
  • No security risks – No hardcoded secrets, unnecessary privilege escalations, or permission issues.

🛠️ Type of Change (X in brackets)

  • 🐞 Bug fix – Resolves an issue without breaking functionality.
  • New feature – Adds new, non-breaking functionality.
  • 💥 Breaking change – Alters existing functionality in a way that may require updates.
  • 🆕 New script – A fully functional and tested script or script set.
  • 🌍 Website update – Changes to website-related JSON files or metadata.
  • 🔧 Refactoring / Code Cleanup – Improves readability or maintainability without changing functionality.
  • 📝 Documentation update – Changes to README, AppName.md, CONTRIBUTING.md, or other docs.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/community-scripts/ProxmoxVE/pull/4292 **Author:** [@MickLesk](https://github.com/MickLesk) **Created:** 5/7/2025 **Status:** ✅ Merged **Merged:** 5/7/2025 **Merged by:** [@tremor021](https://github.com/tremor021) **Base:** `main` ← **Head:** `vm_nextid_feature` --- ### 📝 Commits (1) - [`44c3549`](https://github.com/community-scripts/ProxmoxVE/commit/44c3549afc29f24c95c17d2f2b0c8e5b12df5378) Feature: get correct next VMID ### 📊 Changes **13 files changed** (+270 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `vm/archlinux-vm.sh` (+21 -4) 📝 `vm/debian-vm.sh` (+21 -4) 📝 `vm/docker-vm.sh` (+21 -5) 📝 `vm/haos-vm.sh` (+22 -6) 📝 `vm/mikrotik-routeros.sh` (+18 -3) 📝 `vm/nextcloud-vm.sh` (+21 -6) 📝 `vm/openwrt.sh` (+21 -5) 📝 `vm/opnsense-vm.sh` (+22 -4) 📝 `vm/owncloud-vm.sh` (+22 -6) 📝 `vm/pimox-haos-vm.sh` (+18 -3) 📝 `vm/ubuntu2204-vm.sh` (+21 -6) 📝 `vm/ubuntu2404-vm.sh` (+21 -4) 📝 `vm/ubuntu2410-vm.sh` (+21 -4) </details> ### 📄 Description ## ✍️ Description This PR improves the robustness and usability of the VM creation workflow: - Introduces `get_valid_nextid()`, a helper function to find the next truly available VMID by checking: - `/etc/pve/qemu-server/<id>.conf` - `/etc/pve/lxc/<id>.conf` - orphaned LVM volumes via `lvs` - Ensures that the `whiptail` inputbox for "Virtual Machine ID" is always pre-filled with a valid and unused ID. - Fixes the issue where the input field was empty when `$VMID` was not explicitly set beforehand. - Removes reliance on `pvesh get /cluster/nextid` alone, which may suggest IDs that are technically blocked by orphaned resources. ## Benefits - Prevents script crashes caused by `pvesm alloc` failing on orphaned volumes. - Improves UX in interactive shell scripts (especially when run via SSH or Proxmox GUI). - Ensures reproducibility and automation safety when the script is reused or extended. **Before (Docker-VM without the function):** ![image](https://github.com/user-attachments/assets/5f9ccb8f-4a11-4a1d-880d-49554c4a029b) **After (Debian-VM with the new function) – set ID to 108 instead of 107):** ![image](https://github.com/user-attachments/assets/eee3e8cc-86ec-4661-b4ae-a507cdd51c7d) ## 🔗 Related PR / Issue Link: #4289 ## ✅ Prerequisites (**X** in brackets) - [x] **Self-review completed** – Code follows project standards. - [x] **Tested thoroughly** – Changes work as expected. - [x] **No security risks** – No hardcoded secrets, unnecessary privilege escalations, or permission issues. --- ## 🛠️ Type of Change (**X** in brackets) - [ ] 🐞 **Bug fix** – Resolves an issue without breaking functionality. - [x] ✨ **New feature** – Adds new, non-breaking functionality. - [ ] 💥 **Breaking change** – Alters existing functionality in a way that may require updates. - [ ] 🆕 **New script** – A fully functional and tested script or script set. - [ ] 🌍 **Website update** – Changes to website-related JSON files or metadata. - [ ] 🔧 **Refactoring / Code Cleanup** – Improves readability or maintainability without changing functionality. - [ ] 📝 **Documentation update** – Changes to `README`, `AppName.md`, `CONTRIBUTING.md`, or other docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 14:32:05 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ProxmoxVE#4791
No description provided.