Skip to contentSkip to conversation

hw/usb: Include USB files only if necessary

PATCH Superseded Thomas Huth 2 participants 6 messages Mar 14, 2015 – Mar 17, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/usb: Include USB files only if necessary

Boards that do not include an USB controller should not provide USB devices. However, when running "qemu-system-s390x -device help" for example, there's still a usb-hub, usb-kbd, usb-mouse and usb-tablet in the list of "supported" devices. Let's fix that by compiling and linking the USB files only if it's really necessary.

---
 default-configs/arm-softmmu.mak |    1 +
 default-configs/usb.mak         |    1 +
 hw/usb/Makefile.objs            |    8 ++++----
 3 files changed, 6 insertions(+), 4 deletions(-)
default-configs/arm-softmmu.mak +1 -0
index 87d4e34..a767e4b 100644
@@ -32,6 +32,7 @@ CONFIG_DS1338=y
 CONFIG_PFLASH_CFI01=y
 CONFIG_PFLASH_CFI02=y
 CONFIG_MICRODRIVE=y
+CONFIG_USB=y
 CONFIG_USB_MUSB=y
 CONFIG_USB_EHCI_SYSBUS=y
 CONFIG_PLATFORM_BUS=y
default-configs/usb.mak +1 -0
index 73d8489..f4b8568 100644
@@ -1,3 +1,4 @@
+CONFIG_USB=y
 CONFIG_USB_TABLET_WACOM=y
 CONFIG_USB_STORAGE_BOT=y
 CONFIG_USB_STORAGE_UAS=y
hw/usb/Makefile.objs +4 -4
index 0ccd477..c514831 100644
@@ -1,6 +1,6 @@
 # usb subsystem core
-common-obj-y += core.o combined-packet.o bus.o desc.o desc-msos.o
-common-obj-y += libhw.o
+common-obj-y += core.o bus.o libhw.o
+common-obj-$(CONFIG_USB) +=  combined-packet.o desc.o desc-msos.o
 
 # usb host adapters
 common-obj-$(CONFIG_USB_UHCI) += hcd-uhci.o
@@ -11,8 +11,8 @@ common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o
 common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o
 
 # emulated usb devices
-common-obj-y += dev-hub.o
-common-obj-y += dev-hid.o
+common-obj-$(CONFIG_USB) += dev-hub.o
+common-obj-$(CONFIG_USB) += dev-hid.o
 common-obj-$(CONFIG_USB_TABLET_WACOM) += dev-wacom.o
 common-obj-$(CONFIG_USB_STORAGE_BOT)  += dev-storage.o
 common-obj-$(CONFIG_USB_STORAGE_UAS)  += dev-uas.o
Signature · 1 line
1.7.1
#1 lore raw
Quoted 2 lines · On Sat, 14 Mar 2015 06:33:35 +0100 Thomas Huth <[email protected]> wrote:

Boards that do not include an USB controller should not provide USB devices. However, when running "qemu-system-s390x -device help"

By the way, in case somebody wants to test the above example, and wonders why there are also U/O/E/XHCI controllers in the list of devices - the patch for removing them is currently on the way:

http://lists.nongnu.org/archive/html/qemu-devel/2015-03/msg02722.html

Quoted 6 lines

for example, there's still a usb-hub, usb-kbd, usb-mouse and usb-tablet in the list of "supported" devices. Let's fix that by compiling and linking the USB files only if it's really necessary.

#2 lore raw
In reply to Thomas Huth
Quoted 6 lines · Thomas Huth

Boards that do not include an USB controller should not provide USB devices. However, when running "qemu-system-s390x -device help" for example, there's still a usb-hub, usb-kbd, usb-mouse and usb-tablet in the list of "supported" devices. Let's fix that by compiling and linking the USB files only if it's really necessary.

Added to usb queue.

thanks,
Gerd

#3 lore raw
Quoted 9 lines · Gerd Hoffmann
Quoted 6 lines · Thomas Huth

Boards that do not include an USB controller should not provide USB devices. However, when running "qemu-system-s390x -device help" for example, there's still a usb-hub, usb-kbd, usb-mouse and usb-tablet in the list of "supported" devices. Let's fix that by compiling and linking the USB files only if it's really necessary.

Added to usb queue.

Removed, fails to build.

Needs a complete rebuild due to the new CONFIG_USB option. Hardly avoidable I guess. But even with that done I still get this:

LINK lm32-softmmu/qemu-system-lm32
../hw/usb/redirect.o: In function `usbredir_bulk_packet':
/home/kraxel/projects/qemu/hw/usb/redirect.c:1978: undefined reference to usb_combined_input_packet_complete' ../hw/usb/redirect.o: In function usbredir_flush_ep_queue':
/home/kraxel/projects/qemu/hw/usb/redirect.c:951: undefined reference to `usb_ep_combine_input_packets'
../hw/usb/redirect.o: In function `usbredir_cancel_packet':
/home/kraxel/projects/qemu/hw/usb/redirect.c:367: undefined reference to `usb_combined_packet_cancel'
../hw/usb/host-libusb.o: In function `usb_host_cancel_packet':
/home/kraxel/projects/qemu/hw/usb/host-libusb.c:1014: undefined reference to usb_combined_packet_cancel' ../hw/usb/host-libusb.o: In function usb_host_req_complete_data':
/home/kraxel/projects/qemu/hw/usb/host-libusb.c:396: undefined reference to usb_combined_input_packet_complete' ../hw/usb/host-libusb.o: In function usb_host_flush_ep_queue':
/home/kraxel/projects/qemu/hw/usb/host-libusb.c:1358: undefined reference to `usb_ep_combine_input_packets'
collect2: error: ld returned 1 exit status

cheers,
Gerd

#4 lore raw
Quoted 13 lines · On Tue, 17 Mar 2015 13:19:57 +0100 Gerd Hoffmann <[email protected]> wrote:
Quoted 9 lines · Gerd Hoffmann
Quoted 6 lines · Thomas Huth

Boards that do not include an USB controller should not provide USB devices. However, when running "qemu-system-s390x -device help" for example, there's still a usb-hub, usb-kbd, usb-mouse and usb-tablet in the list of "supported" devices. Let's fix that by compiling and linking the USB files only if it's really necessary.

Added to usb queue.

Removed, fails to build.

Quoted 7 lines

Needs a complete rebuild due to the new CONFIG_USB option. Hardly avoidable I guess. But even with that done I still get this:

LINK lm32-softmmu/qemu-system-lm32
../hw/usb/redirect.o: In function `usbredir_bulk_packet':
/home/kraxel/projects/qemu/hw/usb/redirect.c:1978: undefined reference to `usb_combined_input_packet_complete'

Oh, sorry, seems like I missed the "--enable-usb-redir" configure option ... I'll have a look and rework my patch...

Thomas

#5 lore raw
Quoted 3 lines

Oh, sorry, seems like I missed the "--enable-usb-redir" configure option ... I'll have a look and rework my patch...

Oh, right, that can hide the failure.
Note there also is --enable-libusb

cheers,
Gerd