meta-phosphor: modify nbd proxy port settings
Modify the state_hook to dynamically select a unused port.
fixes openbmc/openbmc#3814
Tested:
1.Login BMC WEB;
2.Go to 'KVM page', the KVM is working OK;
3.Click on 'Open in new tab' to make sure another KVM session is opened;
4.Go to "Virtual media" page, click "Add file", choose an ISO file, and click "Start",verify no error output.
Change-Id: Iba6c682493fe481d0b955d43d0be520cedb5f86f
Signed-off-by: Tingting Chen <chentingting.2150@bytedance.com>
diff --git a/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook b/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
index 3f5a974..063699e 100755
--- a/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
+++ b/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
@@ -27,6 +27,21 @@
set -ex
+GADGET_BASE=/sys/kernel/config/usb_gadget
+
+which_dev()
+{
+ in_use="$(cat $GADGET_BASE/*/UDC)"
+ cd /sys/class/udc
+ for dev in *; do
+ case "$in_use" in
+ *"$dev"*) ;;
+ *) echo "$dev"; return 0;;
+ esac
+ done
+ return 1
+}
+
case "$action" in
start)
mkdir -p $gadget_dir
@@ -48,7 +63,8 @@
echo 1 > functions/mass_storage.usb0/lun.0/ro
echo 0 > functions/mass_storage.usb0/lun.0/cdrom
echo $nbd_device > functions/mass_storage.usb0/lun.0/file
- echo "1e6a0000.usb-vhub:p4" > UDC
+ device=$(which_dev)
+ echo "$device" > UDC
)
;;
stop)