[pve-devel] [PATCH pve-manager v2 07/16] nic pinning: rename 'nic' parameter to 'interface'

Stefan Hanreich s.hanreich at proxmox.com
Fri Jul 18 18:26:29 CEST 2025


From: Thomas Lamprecht <t.lamprecht at proxmox.com>

Note that we do greedy matching for CLI parameters names and allow
using just a single minus too, so as of now one can stills use shorter
variants like `-i IFACE`.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 PVE/CLI/proxmox_network_interface_pinning.pm | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/PVE/CLI/proxmox_network_interface_pinning.pm b/PVE/CLI/proxmox_network_interface_pinning.pm
index f9d94369a..4b7f72404 100644
--- a/PVE/CLI/proxmox_network_interface_pinning.pm
+++ b/PVE/CLI/proxmox_network_interface_pinning.pm
@@ -325,10 +325,12 @@ __PACKAGE__->register_method({
     parameters => {
         additionalProperties => 0,
         properties => {
-            nic => {
-                description => 'Only pin a specific NIC.',
+            # TODO: support a target name or prefix once pve-common supports generic physical ifaces
+            interface => {
+                description => 'Only pin a specific interface.',
                 type => 'string',
                 format => 'pve-iface',
+                default => '<all>', # just for the docs.
                 optional => 1,
             },
         },
@@ -352,20 +354,19 @@ __PACKAGE__->register_method({
         }
 
         my $code = sub {
-            my $prefix = 'nic';
+            my $prefix = 'nic'; # TODO: make flexible once pve-common supports that.
 
             my $ip_links = get_ip_links();
             my $pinned = get_pinned();
             my $existing_pins = resolve_pinned($ip_links, $pinned);
 
-            if ($params->{nic}) {
-                die "Could not find link with name $params->{nic}"
-                    if !$ip_links->{ $params->{nic} };
+            if ($iface) {
+                die "Could not find link with name '$iface'\n" if !$ip_links->{$iface};
 
-                die "There already exists a pin for NIC $params->{nic}"
-                    if $existing_pins->{ $params->{nic} };
+                die "There already exists a pin for NIC '$iface' - aborting.\n"
+                    if $existing_pins->{$iface};
 
-                $ip_links = { $params->{nic} => $ip_links->{ $params->{nic} } };
+                $ip_links = { $iface => $ip_links->{$iface} };
             } else {
                 for my $iface_name (keys $existing_pins->%*) {
                     delete $ip_links->{$iface_name};
-- 
2.39.5




More information about the pve-devel mailing list