Skip to content

docs: document NoPermission for the fan control setters - #148

Merged
brayniac merged 2 commits into
rust-nvml:mainfrom
brayniac:docs/fan-setter-no-permission
Nov 24, 2026
Merged

brayniac merged 2 commits into
rust-nvml:mainfrom
brayniac:docs/fan-setter-no-permission

Conversation

@brayniac

@brayniac brayniac commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Refs #64.

Device::set_fan_speed(), Device::set_default_fan_speed() and Device::set_fan_control_policy() now say "Requires root/admin permissions." and list NoPermission among their errors. #64 reports set_fan_speed() returning NoPermission after the reporter set the /dev/nvidia* device nodes to mode 0666 with udev rules.

Hardware test

I ran a probe built from this branch on an RTX 4090 with driver 550.163.01, in a Debian 13 guest (kernel 6.12) with the GPU passed through. /dev/nvidia0, nvidiactl, nvidia-uvm and nvidia-uvm-tools were already mode 0666 (DeviceFileMode: 438). Results on both fans:

Call uid 1000 root
set_fan_speed(50) NoPermission, policy unchanged Ok, policy Manual
set_default_fan_speed NoPermission Ok, policy TemperatureContinousSw
set_fan_control_policy(Manual) NoPermission Ok, policy Manual
set_fan_control_policy(TemperatureContinousSw) NoPermission Ok

Both fans ended on TemperatureContinousSw.

Not tested:

  • Windows
  • other drivers or GPUs
  • root inside a user namespace or container
  • whether the fan reaches the requested speed (the probe read the speed immediately after the call)

Decisions for the reviewer

  • The NVML header (nvml-wrapper-sys/nvml.h) lists NVML_ERROR_NO_PERMISSION for none of nvmlDeviceSetFanSpeed_v2, nvmlDeviceSetDefaultFanSpeed_v2 or nvmlDeviceSetFanControlPolicy, so each NoPermission entry notes this. The header does say nvmlDeviceSetFanControlPolicy "Requires privileged user".
  • The wording matches the other privileged setters in device.rs: "Requires root/admin permissions." and "if the user doesn't have permission to perform this operation".
  • This PR doesn't close Udev rules ? #64. The test above answers the reporter's question: making the device nodes world-writable doesn't allow fan control, because the calls need root. I'll reply on the issue separately.

Testing

  • cargo fmt --all -- --check: clean.
  • cargo clippy --all-targets --all-features -- -D warnings: clean.
  • cargo doc -p nvml-wrapper --no-deps: the same 4 warnings as on main, in enums/device.rs and enum_wrappers/device.rs.

Review

Three fresh-agent reviews ran before push.

  1. The first review returned "fix first". It found that the draft claimed something the issue doesn't state ("non-root callers have reported it") and used a bare (#64) in rustdoc. The draft also applied one function's report to another and omitted the header caveat on set_fan_control_policy. All four were fixed, and "Closes" became "Refs".
  2. The second review returned "merge". It flagged two overstatements, one in the CHANGELOG and one in the commit message, and both were reworded.
  3. After the hardware test, a third review of the commit that adds the root requirement returned "merge". It found three wording problems, all fixed in the pushed head:
    • an ambiguous CHANGELOG sentence
    • a NoPermission condition stronger than the test shows
    • a commit-message line that credited set_fan_control_policy(TemperatureContinousSw) with a policy reading it didn't produce

Problems seen nearby and not fixed here:

  • the broken link to get_fan_control_policy at enums/device.rs:408
  • "UnexpectedVariant, for which you can read the docs for", which is unfinished in several places

🤖 Generated with Claude Code

brayniac and others added 2 commits November 24, 2026 09:12
Device::set_fan_speed(), Device::set_default_fan_speed() and
Device::set_fan_control_policy() did not list NoPermission among their
errors. rust-nvml#64 reports set_fan_speed() returning it, from a fork of this
crate, after adding udev rules that set the /dev/nvidia* device nodes
to mode 0666. The NVML header's return lists for
nvmlDeviceSetFanSpeed_v2, nvmlDeviceSetDefaultFanSpeed_v2 and
nvmlDeviceSetFanControlPolicy do not include NVML_ERROR_NO_PERMISSION,
so each doc says so.

The header says nvmlDeviceSetFanControlPolicy requires a privileged
user, so Device::set_fan_control_policy() now states that it requires
root/admin permissions.

Also fixes a doubled "the" in set_default_fan_speed()'s summary.

Refs rust-nvml#64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tested on an RTX 4090 with driver 550.163.01 in a Debian 13 guest, with
the /dev/nvidia* nodes at mode 0666 (NVreg DeviceFileMode 438):

- As uid 1000, set_fan_speed(), set_default_fan_speed() and
  set_fan_control_policy() each returned NoPermission on both fans, and
  the fan control policy did not change.
- As root, all three returned Ok. The policy was Manual after
  set_fan_speed() and after set_fan_control_policy(Manual), and
  TemperatureContinousSw after set_default_fan_speed().

So all three now say "Requires root/admin permissions."

Refs rust-nvml#64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brayniac brayniac mentioned this pull request Nov 24, 2026
@brayniac
brayniac merged commit d7e289f into rust-nvml:main Nov 24, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Udev rules ?

1 participant