Skip to content

killswitch: avoid re-blocking devices already in blocked state#1606

Merged
brianmcgillion merged 2 commits intotiiuae:mainfrom
vunnyso:vs-ksFix
Dec 4, 2025
Merged

killswitch: avoid re-blocking devices already in blocked state#1606
brianmcgillion merged 2 commits intotiiuae:mainfrom
vunnyso:vs-ksFix

Conversation

@vunnyso
Copy link
Copy Markdown
Collaborator

@vunnyso vunnyso commented Dec 2, 2025

Description of Changes

Addresses a corner case where the "block --all" command is triggered and some devices are already blocked. To resolve this, I've added logic to detect the current device status and continue the loop if a device is already blocked.

Corner case as described below

This PR:

[ghaf@gui-vm:~]$ ghaf-killswitch block  net
Blocking net device ...
INFO Successfully detached

[ghaf@gui-vm:~]$ ghaf-killswitch block --all
Blocking mic device ...
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
Skipping net - already blocked
Blocking device cam0 ...
INFO Successfully detached
Blocking device bt0 ...
INFO Successfully detached

VS Mainline:

[ghaf@gui-vm:~]$ ghaf-killswitch block  net
Blocking net device ...
INFO Successfully detached

[ghaf@gui-vm:~]$ ghaf-killswitch block --all
Blocking mic device ...
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
INFO Successfully detached
Blocking net device ...
ERROR Failed to detach PCI: Device 0000:2e:00.0 8086:272B (Intel Corporation Wi-Fi 7(802.11be) AX1775*/AX1790*/BE20*/BE401/BE1750* 2x2 (BE200 320MHz [Gale Peak])) is not attached to any VM

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

Will also include fixes from tiiuae/ghafpkgs#154 (Merged)

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64
  • System 76 x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

  1. Detailed steps mentioned in Description of Changes section.
  2. Also fixes https://jira.tii.ae/browse/SSRCSP-7673

@kajusnau
Copy link
Copy Markdown
Collaborator

kajusnau commented Dec 2, 2025

Could you please check my (late) comments on the previous PR #1577 (review), maybe something would apply to the scope of this one, as it's a refactor/bugfix 😀

@vunnyso
Copy link
Copy Markdown
Collaborator Author

vunnyso commented Dec 3, 2025

Ready for review.

@vunnyso vunnyso requested a review from mbssrc December 3, 2025 08:15
Copy link
Copy Markdown
Collaborator

@brianmcgillion brianmcgillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brianmcgillion brianmcgillion added the Needs Testing CI Team to pre-verify label Dec 3, 2025
Addresses a corner case where the "block --all"
command is triggered and some devices are already
blocked. To resolve this, I've added logic to detect
the current device status and continue the loop if
a device is already blocked.

Signed-off-by: Vunny Sodhi <vunny.sodhi@unikie.com>
Ghafpkgs bump includes add periodic status refresh for
ghaf-kill-switch app.

Signed-off-by: Vunny Sodhi <vunny.sodhi@unikie.com>
@vunnyso
Copy link
Copy Markdown
Collaborator Author

vunnyso commented Dec 3, 2025

Last push includes:

  1. Rebased to the latest version.
  2. Fixed the icon size for the app, as the latest cosmic version made the icon appear smaller.

@milva-unikie
Copy link
Copy Markdown

Tested on Darter Pro (new image, did not have a suitable one to rebuild)

  • Works like described in the PR
  • The bug with state not updating to the app has been fixed

@milva-unikie milva-unikie added Tested on System76 and removed Needs Testing CI Team to pre-verify labels Dec 4, 2025
@brianmcgillion brianmcgillion merged commit 25fec0c into tiiuae:main Dec 4, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants