From: Jonas Theisen <j.theisen@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 1/3] api: add mappings to resources endpoint
Date: Wed, 9 Sep 2026 18:29:29 +0200 [thread overview]
Message-ID: <20260909163013.444378-2-j.theisen@proxmox.com> (raw)
In-Reply-To: <20260909163013.444378-1-j.theisen@proxmox.com>
Similar to the SDN zones this patch adds the USB, PCI and
directory mappings to the resources endpoint of the API.
It adds a new type 'mapping' for this and distinguishes
the mappings with 'mapping-type' in the returned object.
This is needed to allow the permissions tab to gather
the IDs of the mappings for the paths list.
Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
PVE/API2/Cluster.pm | 58 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 3 deletions(-)
diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 4e5efbfd..3df03411 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -272,7 +272,7 @@ __PACKAGE__->register_method({
type => 'string',
description => 'Resource type.',
optional => 1,
- enum => ['vm', 'storage', 'node', 'sdn'],
+ enum => ['vm', 'storage', 'node', 'sdn', 'mapping'],
},
},
},
@@ -288,8 +288,17 @@ __PACKAGE__->register_method({
type => {
description => "Resource type.",
type => 'string',
- enum =>
- ['node', 'storage', 'pool', 'qemu', 'lxc', 'openvz', 'sdn', 'network'],
+ enum => [
+ 'node',
+ 'storage',
+ 'pool',
+ 'qemu',
+ 'lxc',
+ 'openvz',
+ 'sdn',
+ 'network',
+ 'mapping',
+ ],
},
status => {
description => "Resource type dependent status.",
@@ -503,6 +512,17 @@ __PACKAGE__->register_method({
default => 'x86_64',
optional => 1,
},
+ mapping => {
+ description => "The name of the mapping (for type 'mapping')",
+ type => "string",
+ optional => 1,
+ },
+ 'mapping-type' => {
+ description => "The type of the mapping (for type 'mapping')",
+ type => "string",
+ enum => ["pci", "usb", "dir"],
+ optional => 1,
+ },
},
},
},
@@ -723,6 +743,38 @@ __PACKAGE__->register_method({
}
}
+ if (!$param->{type} || $param->{type} eq 'mapping') {
+ my $can_see_mapping_privs = ['Mapping.Modify', 'Mapping.Use', 'Mapping.Audit'];
+
+ foreach my $mapping_type ('pci', 'usb', 'dir') {
+ my $cfg = {};
+
+ if ($mapping_type eq 'pci') {
+ $cfg = PVE::Mapping::PCI::config();
+ } elsif ($mapping_type eq 'usb') {
+ $cfg = PVE::Mapping::USB::config();
+ } elsif ($mapping_type eq 'dir') {
+ $cfg = PVE::Mapping::Dir::config();
+ }
+
+ for my $id (keys $cfg->{ids}->%*) {
+ next
+ if !($rpcenv->check(
+ $authuser, "/mapping/$mapping_type/$id", $can_see_mapping_privs, 1,
+ ));
+ next if !$cfg->{ids}->{$id};
+
+ push @$res,
+ {
+ id => "mapping/$mapping_type/$id",
+ mapping => $id,
+ 'mapping-type' => $mapping_type,
+ type => 'mapping',
+ };
+ }
+ }
+ }
+
return $res;
},
});
--
2.47.3
next prev parent reply other threads:[~2026-09-09 16:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 16:29 [PATCH pve-manager 0/3] show mappings in ACL path selector Jonas Theisen
2026-09-09 16:29 ` Jonas Theisen [this message]
2026-09-09 16:29 ` [PATCH pve-manager 2/3] ui: acl: add mappings to ACL path list Jonas Theisen
2026-09-09 16:29 ` [PATCH pve-manager 3/3] ui: resource-tree: filter newly added mappings Jonas Theisen
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=20260909163013.444378-2-j.theisen@proxmox.com \
--to=j.theisen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.