[PATCH] hw/usb: record async control completion for parameter transfers

Ziyi Fu posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260626080554.1656771-1-ziyifu970225@gmail.com
hw/usb/core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] hw/usb: record async control completion for parameter transfers
Posted by Ziyi Fu 1 month ago
From: Ziyi Fu <ziyi.fu@cyberus-technology.de>

Record the completion side of parameter-based control transfers when they
complete asynchronously. This lets pcap captures include descriptor
response data for requests such as GET_DESCRIPTOR from usb-host devices.

The synchronous path already recorded the completion, but the async
SETUP_STATE_PARAM path was missing it.

Signed-off-by: Ziyi Fu <ziyi.fu@cyberus-technology.de>
---
Tested with a usb-host HID keyboard on qemu-xhci. Before this change, the
generated pcap contained GET_DESCRIPTOR submissions but not the corresponding
completion payloads. After this change, the pcap contains the descriptor
payloads and Wireshark can associate endpoint 0x81 with the HID interface.

 hw/usb/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/core.c b/hw/usb/core.c
index 9572a870cc..d71204c5c8 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -345,6 +345,7 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p)
             p->actual_length = 0;
             usb_packet_copy(p, s->data_buf, s->setup_len);
         }
+        usb_pcap_ctrl(p, false);
         break;
 
     default:
-- 
2.51.2
Re: [PATCH] hw/usb: record async control completion for parameter transfers
Posted by Michael Tokarev 2 days, 1 hour ago
On 6/26/26 11:05, Ziyi Fu wrote:
> From: Ziyi Fu <ziyi.fu@cyberus-technology.de>
> 
> Record the completion side of parameter-based control transfers when they
> complete asynchronously. This lets pcap captures include descriptor
> response data for requests such as GET_DESCRIPTOR from usb-host devices.
> 
> The synchronous path already recorded the completion, but the async
> SETUP_STATE_PARAM path was missing it.
> 
> Signed-off-by: Ziyi Fu <ziyi.fu@cyberus-technology.de>

Fixes: 0f6dba145a4b ("usb: add pcap support.")

Applied to the trivial-patches tree.

Thanks!

/mjt
Re: [PATCH] hw/usb: record async control completion for parameter transfers
Posted by Marc-André Lureau 3 weeks, 4 days ago
On Fri, Jun 26, 2026 at 4:05 PM Ziyi Fu <ziyifu970225@gmail.com> wrote:
>
> From: Ziyi Fu <ziyi.fu@cyberus-technology.de>
>
> Record the completion side of parameter-based control transfers when they
> complete asynchronously. This lets pcap captures include descriptor
> response data for requests such as GET_DESCRIPTOR from usb-host devices.
>
> The synchronous path already recorded the completion, but the async
> SETUP_STATE_PARAM path was missing it.
>
> Signed-off-by: Ziyi Fu <ziyi.fu@cyberus-technology.de>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
> Tested with a usb-host HID keyboard on qemu-xhci. Before this change, the
> generated pcap contained GET_DESCRIPTOR submissions but not the corresponding
> completion payloads. After this change, the pcap contains the descriptor
> payloads and Wireshark can associate endpoint 0x81 with the HID interface.
>
>  hw/usb/core.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/usb/core.c b/hw/usb/core.c
> index 9572a870cc..d71204c5c8 100644
> --- a/hw/usb/core.c
> +++ b/hw/usb/core.c
> @@ -345,6 +345,7 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p)
>              p->actual_length = 0;
>              usb_packet_copy(p, s->data_buf, s->setup_len);
>          }
> +        usb_pcap_ctrl(p, false);
>          break;
>
>      default:
> --
> 2.51.2
>


-- 
Marc-André Lureau