From 3e2eee5868ae2aa9b74b189df18b39040b057ac5 Mon Sep 17 00:00:00 2001 From: Tingting Chen Date: Wed, 21 Sep 2022 23:22:04 +0800 Subject: 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 --- .../recipes-connectivity/jsnbd/jsnbd/state_hook | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3