Skip to content

Seamless transfer of devices between plugin instances#750

Open
adriaan42 wants to merge 2 commits into
redhat-performance:masterfrom
adriaan42:adriaan/device-instance-transfer
Open

Seamless transfer of devices between plugin instances#750
adriaan42 wants to merge 2 commits into
redhat-performance:masterfrom
adriaan42:adriaan/device-instance-transfer

Conversation

@adriaan42

Copy link
Copy Markdown
Contributor

The problem (briefly discussed in #580 (comment)):

  • when moving a device from one plugin instance to another (via instance_aquire_devices, or during dynamic instance_create/instance_destroy), tuning of the device is unapplied (settings reverted back to original) before the new tuning is applied.

This proposal makes the following changes:

  • For device specific tuning via @commands (_(execute|cleanup)_all_device_commands), there is a new argument providing (optionally) the instance from/to which the device is being moved.
  • For @command_(get|set) we can handle all logic in the base plugin class.
    • When un-tuning in the "from" instance, only unapply those settings that are not set in the "to" instance.
    • For the settings that are set in both "from" and "to" instance, apply the new settings without unapplying the old ones, but transfer the proper original value of the setting so that it can be correctly restored.
  • For @command_custom we pass the transfer_instance to the command
    • Command implementation can provide a seamless transfer, or just ignore the new argument, and the current "unapply-then-apply" behavior will remain unchanged.
  • In controller, replace the current calls to _remove_devices_nocheck/_add_devices_nocheck with calls to the new _transfer_device.
  • Adapt the irq plugin, which uses @command_custom, to support seamless device transfer (separate commit).

@adriaan42 adriaan42 force-pushed the adriaan/device-instance-transfer branch from d8ff6ab to 8dac918 Compare February 14, 2025 14:58
@adriaan42 adriaan42 force-pushed the adriaan/device-instance-transfer branch from 8dac918 to a5cfada Compare May 27, 2025 12:18
@adriaan42 adriaan42 force-pushed the adriaan/device-instance-transfer branch from a5cfada to 4e2d161 Compare February 23, 2026 17:14
adriaan42 added 2 commits June 8, 2026 11:24
Enable the transfer of devices from one instance to another without
(temporarily) unapplying the tuning.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
@adriaan42 adriaan42 force-pushed the adriaan/device-instance-transfer branch from 4e2d161 to 05696f1 Compare June 8, 2026 09:25
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: e6c429a0-f4f0-4ea9-8538-85ca6e5bbb0b

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb28ac and 05696f1.

📒 Files selected for processing (13)
  • tuned/daemon/controller.py
  • tuned/plugins/base.py
  • tuned/plugins/hotplug.py
  • tuned/plugins/plugin_bootloader.py
  • tuned/plugins/plugin_disk.py
  • tuned/plugins/plugin_irq.py
  • tuned/plugins/plugin_irqbalance.py
  • tuned/plugins/plugin_mounts.py
  • tuned/plugins/plugin_net.py
  • tuned/plugins/plugin_scheduler.py
  • tuned/plugins/plugin_scsi_host.py
  • tuned/plugins/plugin_systemd.py
  • tuned/plugins/plugin_vm.py

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved device migration handling between tuning instances with enhanced transfer-aware logic across the controller and plugin layers
    • Refactored device transfer workflow to use standardized transfer context parameters for more consistent device management operations

Walkthrough

This PR adds device transfer support to the tuned system, allowing devices to move between plugin instances while preserving applied tuning settings and persisted state. The implementation spans from controller-level orchestration through base plugin infrastructure to specific plugin implementations.

Changes

Device Transfer Between Plugin Instances

Layer / File(s) Summary
Device transfer orchestration in Controller
tuned/daemon/controller.py
instance_acquire_devices, instance_create, and instance_destroy now use plugin._transfer_device(...) to move devices instead of direct remove/add operations, iterating over plugin instances directly.
Base Plugin transfer-aware command execution
tuned/plugins/base.py
_execute_all_device_commands and _cleanup_all_device_commands gain optional transfer context parameters; custom callbacks updated to accept trailing transfer argument; transfer logic determines source/target for persisted state.
Hotplug device transfer implementation
tuned/plugins/hotplug.py
New _transfer_device(from_instance, to_instance, device_name) method orchestrates removal with transfer context (skipping scripts) and addition with transfer context (sourcing persisted state); device process helpers forward transfer context to tuning hooks.
Device tuning hook updates
tuned/plugins/plugin_disk.py, tuned/plugins/plugin_net.py, tuned/plugins/plugin_scsi_host.py
Device add/remove tuning hook overrides updated to accept and forward transfer_from_instance / transfer_to_instance to superclass while maintaining per-instance device tracking.
IRQ plugin transfer-aware affinity
tuned/plugins/plugin_irq.py
_apply_irq_affinity and _restore_irq_affinity gain transfer-aware logic to reuse stored affinity during transfer and skip restoration; handlers compute transfer flag from transfer_instance context.
Command handler signature updates across ecosystem
tuned/plugins/plugin_bootloader.py, tuned/plugins/plugin_irqbalance.py, tuned/plugins/plugin_mounts.py, tuned/plugins/plugin_systemd.py, tuned/plugins/plugin_vm.py, tuned/plugins/plugin_scheduler.py
All @command_custom and @command handlers add transfer_instance parameter to conform to transfer-aware execution interface; no internal logic changes in most handlers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: enabling seamless transfer of devices between plugin instances instead of unapplying and reapplying tuning.
Description check ✅ Passed The description comprehensively explains the problem being solved, the proposed solution with technical details about the changes, and references related issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant