diff mbox

hw/usb: Include USB files only if necessary

Message ID 1426311215-12764-1-git-send-email-thuth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Thomas Huth March 14, 2015, 5:33 a.m. UTC
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.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
---
 default-configs/arm-softmmu.mak |    1 +
 default-configs/usb.mak         |    1 +
 hw/usb/Makefile.objs            |    8 ++++----
 3 files changed, 6 insertions(+), 4 deletions(-)

Comments

Thomas Huth March 14, 2015, 5:49 a.m. UTC | #1
On Sat, 14 Mar 2015 06:33:35 +0100
Thomas Huth <thuth@linux.vnet.ibm.com> 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

> 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.
> 
> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Gerd Hoffmann March 17, 2015, 12:05 p.m. UTC | #2
On Sa, 2015-03-14 at 06:33 +0100, Thomas Huth wrote:
> 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
Gerd Hoffmann March 17, 2015, 12:19 p.m. UTC | #3
On Di, 2015-03-17 at 13:05 +0100, Gerd Hoffmann wrote:
> On Sa, 2015-03-14 at 06:33 +0100, Thomas Huth wrote:
> > 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
Thomas Huth March 17, 2015, 12:40 p.m. UTC | #4
On Tue, 17 Mar 2015 13:19:57 +0100
Gerd Hoffmann <kraxel@redhat.com> wrote:

> On Di, 2015-03-17 at 13:05 +0100, Gerd Hoffmann wrote:
> > On Sa, 2015-03-14 at 06:33 +0100, Thomas Huth wrote:
> > > 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'

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

 Thomas
Gerd Hoffmann March 17, 2015, 1:02 p.m. UTC | #5
> 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
diff mbox

Patch

diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 87d4e34..a767e4b 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -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
diff --git a/default-configs/usb.mak b/default-configs/usb.mak
index 73d8489..f4b8568 100644
--- a/default-configs/usb.mak
+++ b/default-configs/usb.mak
@@ -1,3 +1,4 @@ 
+CONFIG_USB=y
 CONFIG_USB_TABLET_WACOM=y
 CONFIG_USB_STORAGE_BOT=y
 CONFIG_USB_STORAGE_UAS=y
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
index 0ccd477..c514831 100644
--- a/hw/usb/Makefile.objs
+++ b/hw/usb/Makefile.objs
@@ -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