public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Zongmin Zhou <min_halo@163.com>
Cc: gregkh@linuxfoundation.org, i@zenithal.me,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	valentina.manea.m@gmail.com,
	Zongmin Zhou <zhouzongmin@kylinos.cn>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v3] usbip: tools: add hint when no exported devices are found
Date: Wed, 1 Apr 2026 10:06:21 -0600	[thread overview]
Message-ID: <8d7000a9-981c-468a-bd4b-60111e0b77e9@linuxfoundation.org> (raw)
In-Reply-To: <6ed1738b-9d15-4311-a0f5-9b1a7db69f8c@163.com>

On 3/31/26 20:47, Zongmin Zhou wrote:
> 
> On 2026/4/1 08:27, Shuah Khan wrote:
>> On 3/31/26 03:58, Zongmin Zhou wrote:
>>> From: Zongmin Zhou <zhouzongmin@kylinos.cn>
>>>
>>> When refresh_exported_devices() finds no devices, it's helpful to
>>> inform users about potential causes. This could be due to:
>>>
>>> 1. The usbip driver module is not loaded.
>>> 2. No devices have been exported yet.
>>>
>>> Add an informational message to guide users when ndevs == 0.
>>>
>>> Message visibility by scenario:
>>> - usbipd (console mode): Show on console/serial, this allows instant
>>>    visibility for debugging.
>>> - usbipd -D (daemon mode): Message logged to syslog, can keep logs for
>>>    later traceability in production. Also can use "journalctl -f" to
>>>    trace on console.
>>>
>>> Suggested-by: Shuah Khan <skhan@linuxfoundation.org>
>>> Signed-off-by: Zongmin Zhou <zhouzongmin@kylinos.cn>
>>> ---
>>> Changes in v3:
>>> - Just add an informational message when no devices are found.
>>> Changes in v2:
>>> - Use system calls directly instead of checking sysfs dir.
>>>
>>>   tools/usb/usbip/libsrc/usbip_host_common.c | 7 +++++++
>>>   1 file changed, 7 insertions(+)
>>>
>>> diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
>>> index ca78aa368476..cd92baee310c 100644
>>> --- a/tools/usb/usbip/libsrc/usbip_host_common.c
>>> +++ b/tools/usb/usbip/libsrc/usbip_host_common.c
>>> @@ -149,6 +149,13 @@ static int refresh_exported_devices(struct usbip_host_driver *hdriver)
>>>           }
>>>       }
>>>   +    if (hdriver->ndevs == 0) {
>>> +        if (!strcmp(hdriver->udev_subsystem, "usb"))
>>> +            info("Please check if %s driver is loaded or export devices.",USBIP_HOST_DRV_NAME);
>>
>> Check coding guidelines and match the new code to the existing. Need a space between
>> the string and the next argument.
>>
>>
>>> +        else
>>> +            info("Please check if %s driver is loaded or export devices.",USBIP_DEVICE_DRV_NAME);
>>
>> When will this be true? Isn't refresh_exported_devices() called from
>>
>> Thinking about this more, since you have to differentiate between
>> host and device, it makes sense to make this change to
>>
>> usbip_device_driver_open() and usbip_host_driver_open()
>> There is an err() message already in both of these routines.
>> that prints the right information.
>>
> Shuah,
> 
> Regarding your comment about the existing err() message in these routines:
> 
> The existing err("please load *.ko") message only triggers when usbip_generic_driver_open()
> returns a non-zero value. Since refresh_exported_devices() always returns 0
> (even when ndevs == 0 and no devices are found), usbip_generic_driver_open()
> only returns non-zero when udev_new() fails.
> 
> Therefore, when ndevs == 0, the existing err() message is never printed,
> so it doesn't actually help users diagnose the "no devices found or driver not load" situation.

Correct. There is no need to remove this. What I am suggesting is these
messages from usbip_device_driver_open() and usbip_host_driver_open()

What I am suggesting changing usbip_device_driver_open() and
usbip_host_driver_open() like this:

if (ret || hdriver->ndevs == 0)
                 info("please load " USBIP_CORE_MOD_NAME ".ko and "
                     USBIP_DEVICE_DRV_NAME ".ko!");


This should solve the problem for you ...

I don't like the idea of adding string compares to refresh_exported_devices()

if (!strcmp(hdriver->udev_subsystem, "usb"))

to differentiate when you can simply leverage the existing code by adding
one more conditional and changing the err() to info()

thanks,
-- Shuah

  reply	other threads:[~2026-04-01 16:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03  8:17 [PATCH] usbip: tools: Add usbip host driver availability check Zongmin Zhou
2026-03-10 22:28 ` Shuah Khan
2026-03-12  2:17   ` Zongmin Zhou
2026-03-23 19:17     ` Shuah Khan
2026-03-25  2:26       ` [PATCH v2] " Zongmin Zhou
2026-03-25  8:58         ` Greg KH
2026-03-26  3:10           ` Zongmin Zhou
2026-03-26  8:43             ` Greg KH
2026-03-26 18:43               ` Shuah Khan
2026-03-27  8:39                 ` Zongmin Zhou
2026-03-27 17:51                   ` Shuah Khan
2026-03-27 18:29                     ` Shuah Khan
2026-03-30  3:10                       ` Zongmin Zhou
2026-03-30 16:44                         ` Shuah Khan
2026-03-31  9:58                           ` [PATCH v3] usbip: tools: add hint when no exported devices are found Zongmin Zhou
2026-04-01  0:27                             ` Shuah Khan
2026-04-01  2:47                               ` Zongmin Zhou
2026-04-01 16:06                                 ` Shuah Khan [this message]
2026-04-02  8:32                                   ` [PATCH v4] " Zongmin Zhou
2026-04-06 21:12                                     ` Shuah Khan
2026-04-07  2:34                                       ` Zongmin Zhou
2026-04-09 17:25                                     ` Shuah Khan
2026-03-11 12:13 ` [PATCH] usbip: tools: Add usbip host driver availability check Greg KH
2026-03-12  2:17   ` Zongmin Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d7000a9-981c-468a-bd4b-60111e0b77e9@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=i@zenithal.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=min_halo@163.com \
    --cc=valentina.manea.m@gmail.com \
    --cc=zhouzongmin@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox