From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 1F6DC1FF0A3 for ; Thu, 01 Oct 2026 14:04:13 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E929C216C6; Thu, 01 Oct 2026 14:04:00 +0200 (CEST) Message-ID: <9618f2d7-5f4e-4c9e-b5d5-8f23467406cf@proxmox.com> Date: Thu, 1 Oct 2026 14:03:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Fiona Ebner Subject: Re: [PATCH guest-common v6 04/18] add module to track previously used guest IDs To: =?UTF-8?Q?Michael_K=C3=B6ppl?= , pve-devel@lists.proxmox.com References: <20260924161510.847362-1-m.koeppl@proxmox.com> <20260924161510.847362-5-m.koeppl@proxmox.com> Content-Language: en-US In-Reply-To: <20260924161510.847362-5-m.koeppl@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1790856233820 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.497 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: EM3J5AHVCYVTYNFN2CWKF4ZNBIYEG6IE X-Message-ID-Hash: EM3J5AHVCYVTYNFN2CWKF4ZNBIYEG6IE X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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. > + > + 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;