From: Fiona Ebner <f.ebner@proxmox.com>
To: "Michael Köppl" <m.koeppl@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH guest-common v6 04/18] add module to track previously used guest IDs
Date: Thu, 1 Oct 2026 14:07:15 +0200 [thread overview]
Message-ID: <4c8d6c38-e5a8-4143-9cd4-8876c0526eb3@proxmox.com> (raw)
In-Reply-To: <9618f2d7-5f4e-4c9e-b5d5-8f23467406cf@proxmox.com>
Am 01.10.26 um 2:04 PM schrieb Fiona Ebner:
> Am 24.09.26 um 6:17 PM schrieb Michael Köppl:
>> diff --git a/src/Makefile b/src/Makefile
>> index 030e7f7..ceba738 100644
>> --- a/src/Makefile
>> +++ b/src/Makefile
>> @@ -14,6 +14,7 @@ install: PVE
>> install -m 0644 PVE/Replication.pm ${PERL5DIR}/PVE/
>> install -m 0644 PVE/StorageTunnel.pm ${PERL5DIR}/PVE/
>> install -m 0644 PVE/Tunnel.pm ${PERL5DIR}/PVE/
>> + install -m 0644 PVE/GuestID.pm ${PERL5DIR}/PVE/
>
> Nit: could be ordered alphabetically
>
>> install -d ${PERL5DIR}/PVE/Mapping
>> install -m 0644 PVE/Mapping/Dir.pm ${PERL5DIR}/PVE/Mapping/
>> install -m 0644 PVE/Mapping/PCI.pm ${PERL5DIR}/PVE/Mapping/
>> diff --git a/src/PVE/GuestID.pm b/src/PVE/GuestID.pm
>
> ---snip 8<---
>
>> +my sub insert_id($ranges, $id) {
>> + my $i = 0;
>> +
>> + while ($i < @$ranges && $ranges->[$i]->[1] < $id) {
>
> Style nit: I'd prefer having an explicit scalar()
>
>> + $i++;
>> + }
>> +
>> + return 0 if $i < @$ranges && $ranges->[$i]->[0] <= $id;
>
> Same here.
>
>> +
>> + splice(@$ranges, $i, 0, [$id, $id]);
>> +
>> + return 1;
>> +}
>> +
>> +sub register_used_id($id) {
>> + cfs_lock_file(
>> + $FILENAME,
>> + 10,
>> + sub {
>> + my $ranges = cfs_read_file($FILENAME);
>> +
>> + return if !insert_id($ranges, $id);
>> +
>> + cfs_write_file($FILENAME, $ranges);
>> + },
>> + );
>> +
>
> Style nit: I'd avoid the blank to make it clear that it's connected
> (makes it harder for new code to accidentally sneak in in-between).
>
>> + if (my $err = $@) {
>> + my $dc_conf = cfs_read_file('datacenter.cfg');
>
> Edge case, but we should error out if reading the datacenter config fails.
>
Sorry, it does already die (there's no eval around it).
>> +
>> + my $emsg = "unable to record guest ID $id as used";
>> + die "$emsg - $err" if $dc_conf->{'next-id'}->{unique};
>> + warn "$emsg - $err";
>> + }
>> +}
>> +
>> +cfs_register_file($FILENAME, \&parse_id_list, \&write_id_list);
>> +
>> +1;
>
>
>
>
>
next prev parent reply other threads:[~2026-10-01 12:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 16:14 [PATCH many v6 00/18] add option to prevent suggesting previously used VMIDs Michael Köppl
2026-09-24 16:14 ` [PATCH cluster v6 01/18] cluster files: add virtual-guest/used-guest-ids Michael Köppl
2026-09-24 16:14 ` [PATCH cluster v6 02/18] datacenter config: add unique subproperty to next-id Michael Köppl
2026-09-24 16:14 ` [PATCH cluster v6 03/18] datacenter config: next-id: add enforce subproperty Michael Köppl
2026-09-24 16:14 ` [PATCH guest-common v6 04/18] add module to track previously used guest IDs Michael Köppl
2026-10-01 12:03 ` Fiona Ebner
2026-10-01 12:07 ` Fiona Ebner [this message]
2026-09-24 16:14 ` [PATCH guest-common v6 05/18] tests: add tests for used guest ID tracking Michael Köppl
2026-10-01 12:03 ` Fiona Ebner
2026-09-24 16:14 ` [PATCH guest-common v6 06/18] abstract config: register used guest ID when creating config Michael Köppl
2026-09-24 16:14 ` [PATCH guest-common v6 07/18] guest id: keep used ID list below the pmxcfs file size limit Michael Köppl
2026-10-01 12:03 ` Fiona Ebner
2026-09-24 16:15 ` [PATCH guest-common v6 08/18] tests: add tests for used-guest-ids max file size handling Michael Köppl
2026-10-01 12:04 ` Fiona Ebner
2026-09-24 16:15 ` [PATCH guest-common v6 09/18] guest id: optionally enforce the next-id range and uniqueness Michael Köppl
2026-10-01 12:03 ` Fiona Ebner
2026-10-01 12:07 ` Fiona Ebner
2026-10-01 12:16 ` Fiona Ebner
2026-09-24 16:15 ` [PATCH qemu-server v6 10/18] api: record VM ID as used on destruction and remote migration Michael Köppl
2026-09-24 16:15 ` [PATCH qemu-server v6 11/18] api, remote migrate: exempt existing VMs from next-id enforcement Michael Köppl
2026-09-24 16:15 ` [PATCH container v6 12/18] api: record CT ID as used on destruction and remote migration Michael Köppl
2026-09-24 16:15 ` [PATCH container v6 13/18] api, migrate: exempt existing CTs from next-id enforcement Michael Köppl
2026-09-24 16:15 ` [PATCH manager v6 14/18] fix #4369: api: optionally only suggest unique IDs Michael Köppl
2026-09-24 16:15 ` [PATCH manager v6 15/18] ui: dc options: rename VMID to guest ID Michael Köppl
2026-09-24 16:15 ` [PATCH manager v6 16/18] fix #4369: ui: dc options: add option for unique VM/CT IDs Michael Köppl
2026-09-24 16:15 ` [PATCH manager v6 17/18] api: nextid: reject IDs forbidden by next-id enforcement Michael Köppl
2026-09-24 16:15 ` [PATCH manager v6 18/18] ui: dc options: add option to enforce next free guest ID settings Michael Köppl
2026-10-01 12:07 ` [PATCH many v6 00/18] add option to prevent suggesting previously used VMIDs Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c8d6c38-e5a8-4143-9cd4-8876c0526eb3@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=m.koeppl@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox