hid: fix incorrect return value for hid.
PATCH 1/1 hid: fix incorrect return value for hid.
The return value of hid_keyboard_write is used to set the packet's actual_length and pass to xhci directly to allow guest know how many byte actually processed. Therefore, return 1 to indicate a successful transfer or it will be considered as a wrong xfer.
--- hw/input/hid.c | 1 + 1 file changed, 1 insertion(+)
hw/input/hid.c +1 -0
@@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len) ledstate |=QEMU_CAPS_LOCK_LED ; }kbd_put_ledstate (ledstate); +return 1 ; }return 0 ; }
Signature · 1 line
2.50.1
Please always send all patches to qemu-devel@ (cc'd) (in this case, in addition to qemu-trivial@).
Quoted 15 lines · ShengYi Hung
The return value of
hid_keyboard_writeis used to set the packet'sactual_lengthand pass to xhci directly to allow guest know how many byte actually processed. Therefore, return 1 to indicate a successful transfer or it will be considered as a wrong xfer.Signed-off-by ShengYi Hung <[email protected]>--- hw/input/hid.c | 1 + 1 file changed, 1 insertion(+)hw/input/hid.c +0
-0
hw/input/hid.c int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len) · line 484
Quoted 7 lines
hw/input/hid.c +1
-0@@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len) ledstate |=QEMU_CAPS_LOCK_LED ; }kbd_put_ledstate (ledstate); +return 1 ; }return 0 ; }
and queued up to the trivial-patches tree.
It's an interesting one, I wonder what the consequences are - for having this at 0 all the time, and for actually making it 1. Did we miss a byte somewhere with current code?
Thanks,
/mjt
Hello Michael:
Thanks for your review and reply, I sent the mail to qemud-devel about a month ago but didn't receive any reply. Therefore, I send the mail to qemu-trivial again and forget CC to qemu-devel. I will be careful next time.
The consequence is that if the guest operating system want to check the actual transfer length of a transfer, it may be regarded as a failed transfer since the actual transfer length is zero originally.
Here is an example from FreeBSD:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288968.
I have workarounded this issue by ignore any error from hid_write.
Interestingly, Parallel seems to share the same issue and can be addressed with the same fix.
Quoted 36 lines · Michael Tokarev
Please always send all patches to qemu-devel@ (cc'd) (in this case, in addition to qemu-trivial@).
Quoted 13 lines · ShengYi Hung
The return value of
hid_keyboard_writeis used to set the packet'sactual_lengthand pass to xhci directly to allow guest know how many byte actually processed. Therefore, return 1 to indicate a successful transfer or it will be considered as a wrong xfer.Signed-off-by ShengYi Hung <[email protected]>--- hw/input/hid.c | 1 + 1 file changed, 1 insertion(+)hw/input/hid.c +0
-0hw/input/hid.c int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len) · line 484
Quoted 7 lines
hw/input/hid.c +1
-0@@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len) ledstate |=QEMU_CAPS_LOCK_LED ; }kbd_put_ledstate (ledstate); +return 1 ; }return 0 ; }Reviewed-by Michael Tokarev <[email protected]>and queued up to the trivial-patches tree.
It's an interesting one, I wonder what the consequences are - for having this at 0 all the time, and for actually making it 1. Did we miss a byte somewhere with current code?
Thanks,
/mjt
Signature · 2 lines
Best Regards. ShengYi Hung.