diff --git a/repos/libports/src/lib/qemu-usb/host.cc b/repos/libports/src/lib/qemu-usb/host.cc index 6255b6b73..0083f9c5c 100644 --- a/repos/libports/src/lib/qemu-usb/host.cc +++ b/repos/libports/src/lib/qemu-usb/host.cc @@ -228,10 +228,19 @@ struct Usb_host_device : List::Element Usb::Packet_descriptor alloc_packet(int length) { - if (!usb_raw.source()->ready_to_submit()) throw -1; + if (length <= 0) { + /* + * XXX Packets without payload are not supported by the packet stream + * currently. Therefore, we use a (small) bogus length + * here and depend on the USB driver to handle this case + * correctly. + */ + length = 4; + } + Usb::Packet_descriptor packet = usb_raw.source()->alloc_packet(length); packet.completion = alloc_completion(); return packet; diff --git a/repos/os/include/usb/packet_handler.h b/repos/os/include/usb/packet_handler.h index f739f0886..2ad6ee637 100644 --- a/repos/os/include/usb/packet_handler.h +++ b/repos/os/include/usb/packet_handler.h @@ -85,6 +85,16 @@ class Usb::Packet_handler throw Usb::Session::Tx::Source::Packet_alloc_failed(); } + if (size == 0) { + /* + * XXX Packets without payload are not supported by the packet + * stream currently. Therefore, we use a (small) bogus + * length here and depend on the USB driver to handle this + * case correctly. + */ + size = 4; + } + while (true) { try { Packet_descriptor p = _connection.source()->alloc_packet(size);