From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D54531FF173 for <inbox@lore.proxmox.com>; Mon, 10 Feb 2025 16:38:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 40F8811A8F; Mon, 10 Feb 2025 16:38:27 +0100 (CET) From: Filip Schauer <f.schauer@proxmox.com> To: pve-devel@lists.proxmox.com Date: Mon, 10 Feb 2025 16:37:27 +0100 Message-Id: <20250210153734.103381-5-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210153734.103381-1-f.schauer@proxmox.com> References: <20250210153734.103381-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.024 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager v3 04/11] introduce hardware rng scanning api X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Signed-off-by: Filip Schauer <f.schauer@proxmox.com> --- PVE/API2/Hardware.pm | 7 ++++++ PVE/API2/Hardware/HWRNG.pm | 47 ++++++++++++++++++++++++++++++++++++++ PVE/API2/Hardware/Makefile | 1 + 3 files changed, 55 insertions(+) create mode 100644 PVE/API2/Hardware/HWRNG.pm diff --git a/PVE/API2/Hardware.pm b/PVE/API2/Hardware.pm index 1c6fd8f5..02503b22 100644 --- a/PVE/API2/Hardware.pm +++ b/PVE/API2/Hardware.pm @@ -6,11 +6,17 @@ use warnings; use PVE::JSONSchema qw(get_standard_option); use PVE::RESTHandler; +use PVE::API2::Hardware::HWRNG; use PVE::API2::Hardware::PCI; use PVE::API2::Hardware::USB; use base qw(PVE::RESTHandler); +__PACKAGE__->register_method ({ + subclass => "PVE::API2::Hardware::HWRNG", + path => 'hwrng', +}); + __PACKAGE__->register_method ({ subclass => "PVE::API2::Hardware::PCI", path => 'pci', @@ -47,6 +53,7 @@ __PACKAGE__->register_method ({ my ($param) = @_; my $res = [ + { type => 'hwrng' }, { type => 'pci' }, { type => 'usb' }, ]; diff --git a/PVE/API2/Hardware/HWRNG.pm b/PVE/API2/Hardware/HWRNG.pm new file mode 100644 index 00000000..1c3ac240 --- /dev/null +++ b/PVE/API2/Hardware/HWRNG.pm @@ -0,0 +1,47 @@ +package PVE::API2::Hardware::HWRNG; + +use strict; +use warnings; + +use PVE::JSONSchema qw(get_standard_option); + +use PVE::QemuServer::RNG qw(check_rng_source); + +use base qw(PVE::RESTHandler); + +__PACKAGE__->register_method({ + name => 'hwrngscan', + path => '', + method => 'GET', + description => "List local Hardware RNG devices.", + protected => 1, + proxyto => "node", + permissions => { + check => ['perm', '/', ['Sys.Audit']], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + }, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + path => { type => 'string'}, + }, + }, + }, + code => sub { + my ($param) = @_; + + eval { PVE::QemuServer::RNG::check_rng_source('/dev/hwrng') }; + if (my $err = $@) { + return []; + } + + return [ { path => '/dev/hwrng' } ]; + } +}); diff --git a/PVE/API2/Hardware/Makefile b/PVE/API2/Hardware/Makefile index 026a8dd6..1e552864 100644 --- a/PVE/API2/Hardware/Makefile +++ b/PVE/API2/Hardware/Makefile @@ -1,6 +1,7 @@ include ../../../defines.mk PERLSOURCE= \ + HWRNG.pm \ PCI.pm \ USB.pm \ -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel