greedy auto-connect doesn't work with hotplug

Bug #1876356 reported by Ian Johnson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Fix Released
Undecided
Paweł Stołowski

Bug Description

The arduino snap has this declaration given to it via the store (see https://forum.snapcraft.io/t/auto-connection-request-for-arduino-raw-usb/15586):

plugs:
  raw-usb:
    allow-auto-connection: true
  serial-port:
    allow-auto-connection:
      slot-snap-type:
        - app
      slots-per-plug: *

and when installing the snap with no hotplug serial-port devices connected, it doesn't have any serial port interfaces connected (as expected). I then connected a physical Arduino (which shows up as a serial-port via USB), and I can see the hotplug interface show up under `snap interface serial-port`, but the slot does not get connected to the hotplug serial-port interface plug on the arduino snap.

I also tried just for kicks a similar situation, but where the hotplug device is connected before installing the snap (and thus auto-connect logic on install should process when the hotplug serial-port slot exists) and it also did not automatically get connected.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Pawel, could you take a look at this? I tried to look at overlord/ifacestate to see if it was trivial to fix the not auto-connecting on install when the slot already exists, and I don't see where this is going wrong which leads me to believe that the hotplug interfaces are maybe not showing up in the auto-connect candidates at all when we process the auto-connect event?

Changed in snapd:
status: New → Confirmed
assignee: nobody → Paweł Stołowski (stolowski)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

@Ian I had a quick look (with no way of reproducing easily due to specific setup) and I *think* this is because the declaration says slot-snap-type must be an app (for auto-connect to kick in). Hotplug slots are created on the system snap.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This is a bug in the issued snap declaration, which is trying to work around: https://bugs.launchpad.net/snapstore/+bug/1873282 but did it wrong. I've updated the snap declaration to have:

plugs:
  raw-usb:
    allow-auto-connection: true
  serial-port:
    allow-auto-connection:
      slot-snap-type:
        - gadget
        - core
      slots-per-plug: *

I also did this for the s4a snap.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

@Pawel, should the above also include the 'snapd' as the slot-snap-type?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

(considering we use 'sudo snap set system experimental.hotplug=true' to set the feature and devices show up like 'core:ft232serialuartic' as opposed to 'snapd:foo', I didn't add 'snapd').

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

FYI, it did auto connect here:

$ snap interface serial-port
name: serial-port
summary: allows accessing a specific serial port
plugs:
  - arduino
slots:
  - core:ft232serialuartic (allows accessing a specific serial port)

$ snap connections arduino|grep serial
serial-port arduino:serial-port :ft232serialuartic -

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I installed the snapd snap, made sure it was new enough to be re-execd into, and see:

$ snap interface serial-port
name: serial-port
summary: allows accessing a specific serial port
plugs:
  - arduino
slots:
  - snapd:ft232serialuartic (allows accessing a specific serial port)

$ snap connections arduino|grep serial
serial-port arduino:serial-port :ft232serialuartic -

So while I would want to use 'snapd' in the list for 'slot-snap-type', there is a store bug which prevents this, but thankfully snapd auto-connected the interfaces anyway.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

I just confirmed locally that this now works, even with the snapd snap providing the slots, so I will close this as fix released.

Changed in snapd:
status: Confirmed → Fix Released
Changed in snapd:
milestone: none → 2.44
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.