Potentially connect udc device incorrectly

The fs::directory_iterator doesn't specify the order of enumeration of
folders.  The if-condition here doesn't prevent the folder other than
gadget port, e.g. 1e6a0000.usb-vhub:pX, be taken into account, e.g.
power folder.  In this case, an exception will be generate internally
in connect().  This patch add another check to make sure the folder is
a gadget port.

Without this patch, occasionally obmc-ikvm shows below message and
failed to enumerate USB-HID gadget devices (mouse and keyboard).
```
[  101.840770] Error: Driver 'configfs-gadget' is already registered,
aborting...
[  101.848547] UDC core: obmc_hid: driver registration failed: -16

```

Tested with evb-ast2500 to connect VM, then launch KVM and disconnect
for several times.

Fixes: c11257d864ff ("Connect HID gadget device dynamically")
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
Change-Id: I0cad041d69d580a544e60c79e1c991482ca79819
1 file changed
tree: 460a4375355bc903466e9bf876c9370542548aae
  1. .clang-format
  2. create_usbhid.sh
  3. ikvm_args.cpp
  4. ikvm_args.hpp
  5. ikvm_input.cpp
  6. ikvm_input.hpp
  7. ikvm_manager.cpp
  8. ikvm_manager.hpp
  9. ikvm_server.cpp
  10. ikvm_server.hpp
  11. ikvm_video.cpp
  12. ikvm_video.hpp
  13. LICENSE
  14. meson.build
  15. obmc-ikvm.cpp
  16. OWNERS
  17. README.md
  18. scancodes.hpp
  19. start-ipkvm.service
README.md

OpenBMC IpKVM Server

The obmc-ikvm application is a VNC server that provides access to the host graphics output. The application interfaces with the video device on the BMC that captures the host graphics, and then serves that video data on the RFB (remote framebuffer, also known as VNC) protocol. The application also interfaces with the BMC USB gadget device to pass HID events from the BMC to the host, allowing the user to interact with the host system.

Usage

Once the host is running and an appropriate HID gadget device is instantiated on the BMC, the application can be started with the following command: obmc-ikvm -v <video device path> -i <HID gadget device path>

For example:

obmc-ikvm -v /dev/video0 -i /dev/hidg0