public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/3] low-level: install: split out random disk uid generation
Date: Thu, 16 May 2024 12:28:34 +0200	[thread overview]
Message-ID: <20240516102837.422278-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20240516102837.422278-1-c.heiss@proxmox.com>

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 Proxmox/Install.pm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
index c0f8955..c86a574 100644
--- a/Proxmox/Install.pm
+++ b/Proxmox/Install.pm
@@ -169,6 +169,13 @@ sub btrfs_create {
     syscmd($cmd);
 }
 
+# no high randomnes properties, but this is only for the cases where
+# we either have multiple volume groups or zpools from multiple old PVE disks,
+# or we have a disk with both a "$vgname" and "$vgname-old" ...
+sub random_short_uid {
+    return sprintf "%08X", rand(0xffffffff);
+}
+
 sub zfs_create_rpool {
     my ($vdev, $pool_name, $root_volume_name) = @_;
 
@@ -376,12 +383,7 @@ sub ask_existing_vg_rename_or_abort {
 
     for my $vg_uuid (keys %$duplicate_vgs) {
 	my $vg = $duplicate_vgs->{$vg_uuid};
-
-	# no high randomnes properties, but this is only for the cases where
-	# we either have multiple "$vgname" vgs from multiple old PVE disks, or
-	# we have a disk with both a "$vgname" and "$vgname-old"...
-	my $short_uid = sprintf "%08X", rand(0xffffffff);
-	$vg->{new_vgname} = "$vgname-OLD-$short_uid";
+	$vg->{new_vgname} = "$vgname-OLD-" . random_short_uid();
     }
 
     my $response_ok = Proxmox::Install::Config::get_lvm_auto_rename();
-- 
2.44.0



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2024-05-16 10:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 10:28 [pve-devel] [PATCH installer 0/3] add check/rename for already-existing ZFS rpool Christoph Heiss
2024-05-16 10:28 ` [pve-devel] [PATCH installer 1/3] low-level: add zfs module for retrieving importable zpool info Christoph Heiss
2024-07-08 14:24   ` Aaron Lauterer
2024-07-08 15:13     ` Christoph Heiss
2024-05-16 10:28 ` Christoph Heiss [this message]
2024-05-16 10:28 ` [pve-devel] [PATCH installer 3/3] low-level: install: check for already-existing `rpool` on install Christoph Heiss
2024-07-08 14:16   ` Aaron Lauterer
2024-07-08 15:16     ` Christoph Heiss
2024-07-08 11:27 ` [pve-devel] [PATCH installer 0/3] add check/rename for already-existing ZFS rpool Christoph Heiss
2024-07-11 12:00 ` Christoph Heiss

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=20240516102837.422278-3-c.heiss@proxmox.com \
    --to=c.heiss@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal