irakhlin / hassio-usbip-mounter

Apache License 2.0
9 stars 14 forks source link

status?? #3

Open pathia opened 1 year ago

pathia commented 1 year ago

Hi, I saw you opened PR #3895 for this with a linked to this POC code. It ended in a discussion being moved to discord and then the PR was closed. How did it end? I would really like to see usbip support in HassOS.

m4rkireland commented 1 year ago

Any update on this one please?

irakhlin commented 1 year ago

@m4rkireland I am not completely sure where this stands now for being able to officially release but I can give you a better understanding of what the holdups are. I have not had much time to work on this as a new parent but coming up in the next month or so I do have the second half of my parental leave so that may change.

As it currently stands I have been using this addon on my main home assistant instance (running HA OS) for a few months without issue, currently connected to 3 bluetooth dongles. Each dongle is actually one of a few from the home assistant USB bluetooth dongles ( from the 'high performance' list) connected to an orange pi 3 zero boards. One thing I should point out, and this is on me but the actual repo to use is https://github.com/irakhlin/hassio-addons, the usbip-mounter there is up to date, tested and docker images published for the aarch64 and amd64 architecture. As far as the two main issues here with actually making this a really "usable" component I will outline below.

1. Driver Loading: usbip host and client drivers were packaged and compiled into HA OS as of version 9 but they are not loaded or configured. This means before this add-on can actually connect and use the usbip client binaries the kernel module must be loaded at the OS level. At a base level this can be done a few ways, accessing the HA os terminal directly or via the port 22222 root SSH and running: modprobe usbip-host or for a way to persist past a restart: echo 'usbip-host' > /etc/modules-load.d/usb-host.conf

As you can imagine this is not really a great solution to recommend as a finished product. More importantly as it stands, even with protection mode disabled an add-on will not have access to the needed OS level resources, this could be changed (in the supervisor code) but the idea what rightfully shot down by the maintainers as its 1. not secure, 2. A band-aid and not really a solution and 3. breaks the entire model of what an add-on should be, and one thing it shouldn't be is accessing kernel drivers of the host. A real solution would work one of two ways:

  1. A new generic driver load/unload 'plugin' would be written, similar to existing plugins like (https://github.com/home-assistant/plugin-audio/tree/master). Because a plugin is only exposed to supervisor it could be created to have the needed permissions to load and unload drivers. For something like this to be accepted it would need to be generic (ie loading/unloading drivers not just for usbip), expose an API similar to (https://github.com/home-assistant/plugin-observer) that would allow supervisor to make requests to load, unload and get statuses of loaded kernel modules. After that supervisor API could be expanded to include these API calls. This would allow add-ons to include an optional configuration option to make "driver requests to supervisor" which would enable the base functionality necessary for an add-on like this to work.
  2. Alternatively very similar to the first option, instead of a plugin the kernel module loading/unloading could be added to the os-agent, as is already done for controlling the lights on the HA yellow (started tinkering with that here https://github.com/irakhlin/os-agent). Supervisor would still need to be expanded with new API endpoints and would communicate with os-agent over dbus.

After all this is done and there is a functional way to actual load usb drivers, the much more straight forward and simple task can be done to rewrite this add-on with a simple web-ui that could handle viewing currently mounted usbip devices, unmounting, remounting and graceful un-mounting on shutdown/restart.

As I mentioned I may have more time freeing up shortly but before going down this path I wanted to make sure to resync with the home assistant maintainers to make sure this is still the lay of the land and a valid path forward. I am more than happy to take any help or suggestions with clear ways forward

m4rkireland commented 1 year ago

@irakhlin - thank you for taking the time to write out the current status. I think I'll attempt to run it soon in the same method you are running it, but your points make sense about getting it into a proper 'plugin' in the future. Thanks again

AverageJoe89 commented 1 year ago

I have created repo with working version which can be imported using "Addons -> Add repository" - https://github.com/AverageJoe89/hassio-usbip-mounter