[Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure

Cortland Tölva posted 3 patches 7 years, 1 month ago
There is a newer version of this series
[Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Cortland Tölva 7 years, 1 month ago
In preparation for adding user mode emulation support for the
Linux usbfs interface, check for its kernel header.

Signed-off-by: Cortland Tölva <cst@tolva.net>
---
 configure | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 58862d2ae8..5d36f45442 100755
--- a/configure
+++ b/configure
@@ -4235,7 +4235,23 @@ if compile_prog "" "" ; then
   memfd=yes
 fi
 
-
+# check for usbfs
+have_usbfs=no
+if test "$linux_user" = "yes"; then
+  cat > $TMPC << EOF
+#include <linux/usbdevice_fs.h>
+int main(void) {
+#if !defined(USBDEVFS_URB_TYPE_CONTROL)
+#error Missing usbdevfs defintions.
+#else
+	return 0;
+#endif
+}
+EOF
+  if compile_prog "" "" ; then
+    have_usbfs=yes
+  fi
+fi
 
 # check for fallocate
 fallocate=no
@@ -6346,6 +6362,9 @@ fi
 if test "$memfd" = "yes" ; then
   echo "CONFIG_MEMFD=y" >> $config_host_mak
 fi
+if test "$have_usbfs" = "yes" ; then
+  echo "CONFIG_USBFS=y" >> $config_host_mak
+fi
 if test "$fallocate" = "yes" ; then
   echo "CONFIG_FALLOCATE=y" >> $config_host_mak
 fi
-- 
2.11.0

Re: [Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Laurent Vivier 7 years, 1 month ago
Le 19/09/2018 à 10:04, Cortland Tölva a écrit :
> In preparation for adding user mode emulation support for the
> Linux usbfs interface, check for its kernel header.
> 
> Signed-off-by: Cortland Tölva <cst@tolva.net>
> ---
>  configure | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 58862d2ae8..5d36f45442 100755
> --- a/configure
> +++ b/configure
> @@ -4235,7 +4235,23 @@ if compile_prog "" "" ; then
>    memfd=yes
>  fi
>  
> -
> +# check for usbfs
> +have_usbfs=no
> +if test "$linux_user" = "yes"; then
> +  cat > $TMPC << EOF
> +#include <linux/usbdevice_fs.h>
> +int main(void) {
> +#if !defined(USBDEVFS_URB_TYPE_CONTROL)
> +#error Missing usbdevfs defintions.

s/defintions./definitions/

> +#else
> +	return 0;
> +#endif
> +}
> +EOF
> +  if compile_prog "" "" ; then

As you don't check for any lib API, I think you don't need the ld stage,
so you can use compile_object instead (and you don't need the main body)

Thanks,
Laurent


Re: [Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Laurent Vivier 7 years, 1 month ago
Le 19/09/2018 à 15:39, Laurent Vivier a écrit :
> Le 19/09/2018 à 10:04, Cortland Tölva a écrit :
>> In preparation for adding user mode emulation support for the
>> Linux usbfs interface, check for its kernel header.
>>
>> Signed-off-by: Cortland Tölva <cst@tolva.net>
>> ---
>>  configure | 21 ++++++++++++++++++++-
>>  1 file changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 58862d2ae8..5d36f45442 100755
>> --- a/configure
>> +++ b/configure
>> @@ -4235,7 +4235,23 @@ if compile_prog "" "" ; then
>>    memfd=yes
>>  fi
>>  
>> -
>> +# check for usbfs
>> +have_usbfs=no
>> +if test "$linux_user" = "yes"; then
>> +  cat > $TMPC << EOF
>> +#include <linux/usbdevice_fs.h>
>> +int main(void) {
>> +#if !defined(USBDEVFS_URB_TYPE_CONTROL)
>> +#error Missing usbdevfs defintions.
> 
> s/defintions./definitions/
> 
>> +#else
>> +	return 0;
>> +#endif
>> +}
>> +EOF
>> +  if compile_prog "" "" ; then
> 
> As you don't check for any lib API, I think you don't need the ld stage,
> so you can use compile_object instead (and you don't need the main body)

BTW, I think it's enough to do a "check_include linux/usbdevice_fs.h" as
the symbol has no special meaning and you only need to know if the file
is present to include it.

Thanks,
Laurent

Re: [Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Blake Tölva 7 years, 1 month ago
Thanks Laurent, I have updated the patch.  Should I resend the whole
series to the list?
I believe the third patch may also need revision as the call to
thunk_convert at the end
of do_ioctl_usbdevfs_reapurb seems clunky.  Would love some comments.

On Wed, Sep 19, 2018 at 6:49 AM, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 19/09/2018 à 15:39, Laurent Vivier a écrit :
>> Le 19/09/2018 à 10:04, Cortland Tölva a écrit :
>>> In preparation for adding user mode emulation support for the
>>> Linux usbfs interface, check for its kernel header.
>>>
>>> Signed-off-by: Cortland Tölva <cst@tolva.net>
>>> ---
>>>  configure | 21 ++++++++++++++++++++-
>>>  1 file changed, 20 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/configure b/configure
>>> index 58862d2ae8..5d36f45442 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -4235,7 +4235,23 @@ if compile_prog "" "" ; then
>>>    memfd=yes
>>>  fi
>>>
>>> -
>>> +# check for usbfs
>>> +have_usbfs=no
>>> +if test "$linux_user" = "yes"; then
>>> +  cat > $TMPC << EOF
>>> +#include <linux/usbdevice_fs.h>
>>> +int main(void) {
>>> +#if !defined(USBDEVFS_URB_TYPE_CONTROL)
>>> +#error Missing usbdevfs defintions.
>>
>> s/defintions./definitions/
>>
>>> +#else
>>> +    return 0;
>>> +#endif
>>> +}
>>> +EOF
>>> +  if compile_prog "" "" ; then
>>
>> As you don't check for any lib API, I think you don't need the ld stage,
>> so you can use compile_object instead (and you don't need the main body)
>
> BTW, I think it's enough to do a "check_include linux/usbdevice_fs.h" as
> the symbol has no special meaning and you only need to know if the file
> is present to include it.
>
> Thanks,
> Laurent

Re: [Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Laurent Vivier 7 years, 1 month ago
Le 23/09/2018 à 06:44, Blake Tölva a écrit :
> Thanks Laurent, I have updated the patch.  Should I resend the whole
> series to the list?

yes.

> I believe the third patch may also need revision as the call to
> thunk_convert at the end
> of do_ioctl_usbdevfs_reapurb seems clunky.  Would love some comments.
> 
I didn't read your comment before reviewing this patch. I'm going to
have deeper view on this part.

Thanks,
Laurent

Re: [Qemu-devel] [PATCH 1/3] Check for Linux USBFS in configure
Posted by Cortland Setlow Tölva 7 years, 1 month ago
Hi Laurent,

The deeper view on part 3 can wait - I have found an issue with 64-bit
hosts.  In linux-user/syscall_defs.h the references to struct usbdevfs_urb
and so forth are incorrect and I need to define struct target_usbdevfs_urb
for the size and the ioctl code to be calculated with the target's ABI.

I will send updated patches.

--CST

On Mon, Sep 24, 2018 at 10:22 AM Laurent Vivier <laurent@vivier.eu> wrote:

> Le 23/09/2018 à 06:44, Blake Tölva a écrit :
> > Thanks Laurent, I have updated the patch.  Should I resend the whole
> > series to the list?
>
> yes.
>
> > I believe the third patch may also need revision as the call to
> > thunk_convert at the end
> > of do_ioctl_usbdevfs_reapurb seems clunky.  Would love some comments.
> >
> I didn't read your comment before reviewing this patch. I'm going to
> have deeper view on this part.
>
> Thanks,
> Laurent
>