v0.1.7

VMID and IP Allocation

Last updated


This page explains how QemuRun-pve picks a free VMID when an install request omits id, and how that VMID decides the VM's IP.

VMID to IP Mapping


  1. GATEWAY = 192.168.0.1
  2. VMID = 120
  3. IP = 192.168.0.120/24 (first three octets of GATEWAY + VMID)

Because the last IP octet is the VMID, VMIDs must fall within 100–254: below 100 is reserved by Proxmox, above 254 is not a valid host address.

Probe Range


VariableDefaultCorrection
ASSIGN_IP_START1000 or < 100 → 100
ASSIGN_IP_END2540 or > 254 → 254

A reversed range is swapped automatically.

Two-Ended Concurrent Probe


Each round spawns one goroutine for start and one for end, then moves start++ and end-- until the two meet. A semaphore of size 10 caps concurrent probes.
Each candidate VMID is checked in order and dropped on the first hit:
OrderCheckA hit means
1/etc/pve/nodes/*/qemu-server/<vmid>.conf existsSome node already has this VMID
2qm config <vmid> succeedsProxmox knows this VMID
3192.168.0.<vmid>:22 accepts a connection within 2 secondsA host already uses that IP

The first VMID that passes all three is sent to the result channel, and every unfinished probe is cancelled.

Results


CaseResult
Free VMID foundUsed as the VMID and last IP octet
Every VMID takencannot find available IP
No result within 10 secondstimeout: no available IP found
中文