summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTingting Chen <chentingting.2150@bytedance.com>2022-09-21 18:22:04 +0300
committerTingting Chen <chentingting.2150@bytedance.com>2022-11-01 12:06:07 +0300
commit3e2eee5868ae2aa9b74b189df18b39040b057ac5 (patch)
tree8161aaf66a397562cfa0bc720a730dbadf88fdcc
parent67aa1fd0a041be38f35229bed9b5123420b640e1 (diff)
downloadopenbmc-3e2eee5868ae2aa9b74b189df18b39040b057ac5.tar.xz
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>
-rwxr-xr-xmeta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook18
1 files changed, 17 insertions, 1 deletions
diff --git a/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook b/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
index 3f5a974b95..063699edf3 100755
--- a/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
+++ b/meta-phosphor/recipes-connectivity/jsnbd/jsnbd/state_hook
@@ -27,6 +27,21 @@ esac
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 @@ start)
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)