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 498991FF13E for ; Wed, 01 Jul 2026 16:13:51 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 47042213EE; Wed, 01 Jul 2026 16:13:45 +0200 (CEST) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH container v10 04/10] lxc config: add helper for parsing volid and checking if storage exists Date: Wed, 1 Jul 2026 16:13:33 +0200 Message-ID: <20260701141339.181276-5-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260701141339.181276-1-m.koeppl@proxmox.com> References: <20260701141339.181276-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782915215709 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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: GTITRTEFINFJ6MVTW5QIHSDLTC46C46Z X-Message-ID-Hash: GTITRTEFINFJ6MVTW5QIHSDLTC46C46Z X-MailFrom: m.koeppl@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: Add a helper function to avoid repetition across multiple call sites where a volume id is parsed and functions check for the existence of the given storage, log a warning and return if it does not exist, and perform some action otherwise (e.g. adding a disk as unused). Signed-off-by: Michael Köppl --- src/PVE/LXC/Config.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index c8098538..57c93e8a 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -11,6 +11,7 @@ use PVE::DataCenterConfig; use PVE::GuestHelpers; use PVE::INotify; use PVE::JSONSchema qw(get_standard_option); +use PVE::RESTEnvironment; use PVE::Tools; use PVE::LXC; @@ -1609,6 +1610,20 @@ sub calculate_memory_constraints { return ($memory_max, $memory_high); } +# Skip and warn if a volume's backing storage was already removed from the storage config, so +# guest/volume removal can still proceed. +sub with_checked_volid { + my ($storecfg, $volid, $callback) = @_; + + my ($storeid) = PVE::Storage::parse_volume_id($volid); + if (PVE::Storage::storage_config($storecfg, $storeid, 1)) { + $callback->(); + } else { + PVE::RESTEnvironment::log_warn( + "storage '$storeid' no longer exists, volume '$volid' will be removed"); + } +} + my $LXC_FASTPLUG_OPTIONS = { 'description' => 1, 'onboot' => 1, -- 2.47.3