Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From b5e4fa8886c09c676a28279369d9ea334bdb77bb Mon Sep 17 00:00:00 2001
From: Liang1 Yang <liang1.yang@intel.com>
Date: Thu, 30 Oct 2025 20:07:41 +0800
Subject: [PATCH 1/1] hw/usb/host-libusb: Do not assert when detects invalid
alt

Log warning and skip the interface instead of asserting in qemu
host-libusb when there is invalid altsetting index during fast
USB device hotplug/unplug.
This is to prevent guest vm from crashing which is caused by
QEMU task abort.

Signed-off-by: Liang1 Yang <liang1.yang@intel.com>
---
hw/usb/host-libusb.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 691bc881fb..3a08caafa5 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -885,6 +885,15 @@ static void usb_host_ep_update(USBHostDevice *s)
trace_usb_host_parse_config(s->bus_num, s->addr,
conf->bConfigurationValue, true);

+ /* Log and skip if configuration is NULL or has no interfaces */
+ if (!conf || conf->bNumInterfaces == 0) {
+ warn_report("usb-host: ignoring invalid configuration "
+ "for device %s (bus=%03d, addr=%03d)",
+ udev->product_desc ? udev->product_desc : "unknown",
+ s->bus_num, s->addr);
+ return;
+ }
+
for (i = 0; i < conf->bNumInterfaces; i++) {
/*
* The udev->altsetting array indexes alternate settings
@@ -896,7 +905,21 @@ static void usb_host_ep_update(USBHostDevice *s)
alt = udev->altsetting[intf->bInterfaceNumber];

if (alt != 0) {
- assert(alt < conf->interface[i].num_altsetting);
+ if (alt >= conf->interface[i].num_altsetting) {
+ /*
+ * Recommend fix: sometimes libusb reports a temporary
+ * invalid altsetting index during fast hotplug/unplug.
+ * Instead of aborting, log a warning and skip the interface.
+ */
+ warn_report("usb-host: ignoring invalid altsetting=%d (max=%d) "
+ "for interface=%d on %s (bus=%03d, addr=%03d)",
+ alt,
+ conf->interface[i].num_altsetting ? conf->interface[i].num_altsetting - 1 : -1,
+ i,
+ udev->product_desc ? udev->product_desc : "unknown",
+ s->bus_num, s->addr);
+ continue;
+ }
intf = &conf->interface[i].altsetting[alt];
}

--
2.35.3

7 changes: 6 additions & 1 deletion SPECS/qemu/qemu.spec
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ Obsoletes: sgabios-bin <= 1:0.20180715git-10.fc38
Summary: QEMU is a FAST! processor emulator
Name: qemu
Version: 9.1.0
Release: 3%{?dist}
Release: 4%{?dist}
License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND FSFAP AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-2.0-or-later WITH GCC-exception-2.0 AND LGPL-2.0-only AND LGPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND MIT AND LicenseRef-Fedora-Public-Domain AND CC-BY-3.0
URL: http://www.qemu.org/

Expand Down Expand Up @@ -539,6 +539,7 @@ Patch57: 0054-hw-display-virtio-gpu-Redundant-call-of-dpy_gfx_repl.patch
Patch58: 0055-hw-display-virtio-gpu-Manual-res-flush-to-redraw-sav.patch
Patch59: 0056-hw-display-virtio-gpu-Properly-free-current_cursor.patch
Patch60: 0057-ui-gtk-Re-grabbing-PTR-KBD-individually.patch
Patch61: 0058-hw-usb-host-libusb-Do-not-assert-when-detects-invali.patch

BuildRequires: gnupg2
BuildRequires: meson >= %{meson_version}
Expand Down Expand Up @@ -3537,6 +3538,10 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \


%changelog
* Thu Oct 30 2025 Liang Yang <liang1.yang@intel.com> - 9.1.0-4
- Added 1 patch from Intel Distribution Qemu Commit 3fbf5c5
- Fix assert in qemu host-libusb when altsetting invalid

* Wed Sep 24 2025 Dongwon Kim <dongwon.kim@intel.com> - 9.1.0-3
- Added 3 patches from Intel Distribution Qemu Commit 2a16676
- IOmediator save/restore fix
Expand Down