From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611337851; cv=none; d=zohomail.com; s=zohoarc; b=CMWms1LyYKnIqxLbnbJ/dvd6dr2KapvFUqRqnHkI9awnKTp5//NNtnDVPSgjh7dzgslRPm1LyuwYowypMAvKLhLaL3t0glVWKIOIxYZ7RjAggwZAAJZFFkz6PzVg8jJ8pmqdQDM7mxIhMs8euzBCRi6eLHF6R+xgrm5635Wi1Wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611337851; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cPfC7/Ok/gaWxY81JCfGAmqw+rQx5cybVM6Evx2CXL8=; b=HRQC2QnGwa6dsRy4PyohdDGLNYSc9v0t1niaTE1nqa0gqmA7Bb0ySEwIgVpuB6T0YnYsfotGsMhtWzs94HgCkVeJq0QuNcUlYreEp2u/S/vbyErHs+LH6t9d2KbhPKbGYN/Prgj7rvEcEG7kUdrq0Bx+dO3LVztIkape75lbkVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611337851609631.0324025247976; Fri, 22 Jan 2021 09:50:51 -0800 (PST) Received: from localhost ([::1]:48022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30aA-00057n-EC for importer@patchew.org; Fri, 22 Jan 2021 12:50:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YR-0003LZ-V9 for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YO-0004eg-0C for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-2AtUqbALP8GvopoobuRZJg-1; Fri, 22 Jan 2021 12:48:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF96F80666F; Fri, 22 Jan 2021 17:48:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 983A010190AA; Fri, 22 Jan 2021 17:48:51 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 04CC818000B7; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cPfC7/Ok/gaWxY81JCfGAmqw+rQx5cybVM6Evx2CXL8=; b=CAeE6czlVdUqIhWlBKZYqS/i84r8sQZ18qLdC5a9EFfSHieAd6WJuhlq1hVvQDrRxDZ7pB Hu5wfBN/rjUxxm6iajdM3tNjLVu4i/GGGzHxxPU/bL4GwenG96bdMXvxfiTSykCWNpsHue jewfQmpF5MyLeeGb1KJYYZUuEEcu2jA= X-MC-Unique: 2AtUqbALP8GvopoobuRZJg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 1/8] hw/usb/host-libusb.c: fix build with kernel < 5.0 Date: Fri, 22 Jan 2021 18:48:42 +0100 Message-Id: <20210122174849.3936119-2-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Paolo Bonzini , Gerd Hoffmann , qemu-block@nongnu.org, Fabrice Fontaine Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Fabrice Fontaine USBDEVFS_GET_SPEED is used since version 5.2.0 and https://gitlab.com/qemu-project/qemu/-/commit/202d69a715a4b1824dcd7ec1683d0= 27ed2bae6d3 resulting in the following build failure with kernel < 5.0: ../hw/usb/host-libusb.c: In function 'usb_host_open': ../hw/usb/host-libusb.c:953:32: error: 'USBDEVFS_GET_SPEED' undeclared (fir= st use in this function); did you mean 'USBDEVFS_GETDRIVER'? int rc =3D ioctl(hostfd, USBDEVFS_GET_SPEED, NULL); ^~~~~~~~~~~~~~~~~~ USBDEVFS_GETDRIVER A tentative was made to fix this build failure with https://gitlab.com/qemu-project/qemu/-/commit/4969e697c15ac536d5c0700381d5d= 026ef7f0588 However, the assumption that distros with old kernels also have old libusb is just wrong so also add a check for defined(USBDEVFS_GET_SPEED) Signed-off-by: Fabrice Fontaine Message-id: 20201213213016.457350-1-fontaine.fabrice@gmail.com [ kraxel: codestyle whitespace fixup ] Signed-off-by: Gerd Hoffmann --- hw/usb/host-libusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index b950501d100f..295d20227ad3 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -941,7 +941,8 @@ static int usb_host_open(USBHostDevice *s, libusb_devic= e *dev, int hostfd) usb_host_ep_update(s); =20 libusb_speed =3D libusb_get_device_speed(dev); -#if LIBUSB_API_VERSION >=3D 0x01000107 && defined(CONFIG_LINUX) +#if LIBUSB_API_VERSION >=3D 0x01000107 && defined(CONFIG_LINUX) && \ + defined(USBDEVFS_GET_SPEED) if (hostfd && libusb_speed =3D=3D 0) { /* * Workaround libusb bug: libusb_get_device_speed() does not --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611338166; cv=none; d=zohomail.com; s=zohoarc; b=HvW4YcogGBcKWaXtW1kIXcXwnL5/oHeYqijENLGl74dJg/ekqmZVbQ3z1ds+lnasr/Pen8bUaxJmog5VpFki+aScchX0Q6DvpH3OWOWDdTCkz6fXJM00/XfGl19/gjrKzogwT1bGeXfe/OHKn5OGnG2TIY3MyqNyiCU7kHCwaI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611338166; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iOmA4H82n53CHY8CKN/ropxq/3ofE9GWytjqV9yxWtc=; b=bD7BUUzh1bPGgdUiqqFScpS8VKtPNYlpNd9ThUjKjFbtqjqnKnqQrZm96ic/XwnlYBrmZ80WgXOPjE9n892mVkL1YKvvDjHZXlxTyp6MyDBChjDvfi8HFhOttiLK59CGkOUNg655ksVywx62b+BEUjKiezbTmDndB0SzAHDuyLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611338166048878.7217714830476; Fri, 22 Jan 2021 09:56:06 -0800 (PST) Received: from localhost ([::1]:34788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30fF-00039X-0z for importer@patchew.org; Fri, 22 Jan 2021 12:56:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YV-0003T1-1Y for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YO-0004ep-2v for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-538-V6apRFA_OJi8IA8HitLx8g-1; Fri, 22 Jan 2021 12:48:56 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A161107ACFA; Fri, 22 Jan 2021 17:48:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 930666F139; Fri, 22 Jan 2021 17:48:51 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 151481800389; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iOmA4H82n53CHY8CKN/ropxq/3ofE9GWytjqV9yxWtc=; b=KImFS+k31csij9Qe//1GAwSECi1f80An9wW1tkav9j6tMy3wBGBx7J2Q+OmGR/rJ67PzhT 33XySURLyI+afIfEn6bsKku8/5pxwyzGYwi0w7lMshDg+391ToNZh41UwpcDc7AdHgZ9zp P5jgADCWnbJ0iW4M77pr4lOk7iTZ3xE= X-MC-Unique: V6apRFA_OJi8IA8HitLx8g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 2/8] hw/usb: Fix bad printf format specifiers Date: Fri, 22 Jan 2021 18:48:43 +0100 Message-Id: <20210122174849.3936119-3-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-block@nongnu.org, Alex Chen , Gerd Hoffmann , Euler Robot , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alex Chen We should use printf format specifier "%u" instead of "%d" for argument of type "unsigned int". Reported-by: Euler Robot Signed-off-by: Alex Chen Message-id: 20201119025751.45750-1-alex.chen@huawei.com Signed-off-by: Gerd Hoffmann --- hw/usb/ccid-card-passthru.c | 2 +- hw/usb/core.c | 4 ++-- hw/usb/dev-smartcard-reader.c | 8 ++++---- hw/usb/hcd-ehci.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index c27c60269782..c1a90fcc7a52 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -336,7 +336,7 @@ static void passthru_apdu_from_guest( PassthruState *card =3D PASSTHRU_CCID_CARD(base); =20 if (!qemu_chr_fe_backend_connected(&card->cs)) { - printf("ccid-passthru: no chardev, discarding apdu length %d\n", l= en); + printf("ccid-passthru: no chardev, discarding apdu length %u\n", l= en); return; } ccid_card_vscard_send_apdu(card, apdu, len); diff --git a/hw/usb/core.c b/hw/usb/core.c index e960036f4d5c..c895522a1d5d 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -142,7 +142,7 @@ static void do_token_setup(USBDevice *s, USBPacket *p) setup_len =3D (s->setup_buf[7] << 8) | s->setup_buf[6]; if (setup_len > sizeof(s->data_buf)) { fprintf(stderr, - "usb_generic_handle_packet: ctrl buffer too small (%d > %z= u)\n", + "usb_generic_handle_packet: ctrl buffer too small (%u > %z= u)\n", setup_len, sizeof(s->data_buf)); p->status =3D USB_RET_STALL; return; @@ -277,7 +277,7 @@ static void do_parameter(USBDevice *s, USBPacket *p) setup_len =3D (s->setup_buf[7] << 8) | s->setup_buf[6]; if (setup_len > sizeof(s->data_buf)) { fprintf(stderr, - "usb_generic_handle_packet: ctrl buffer too small (%d > %z= u)\n", + "usb_generic_handle_packet: ctrl buffer too small (%u > %z= u)\n", setup_len, sizeof(s->data_buf)); p->status =3D USB_RET_STALL; return; diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 946df9734a91..80109fa55168 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -945,7 +945,7 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s, CC= ID_XferBlock *recv) return; } len =3D le32_to_cpu(recv->hdr.dwLength); - DPRINTF(s, 1, "%s: seq %d, len %d\n", __func__, + DPRINTF(s, 1, "%s: seq %d, len %u\n", __func__, recv->hdr.bSeq, len); ccid_add_pending_answer(s, (CCID_Header *)recv); if (s->card && len <=3D BULK_OUT_DATA_SIZE) { @@ -995,13 +995,13 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USB= Packet *p) if ((s->bulk_out_pos - 10 < ccid_header->dwLength) && (p->iov.size =3D=3D CCID_MAX_PACKET_SIZE)) { DPRINTF(s, D_VERBOSE, - "usb-ccid: bulk_in: expecting more packets (%d/%d)\n", + "usb-ccid: bulk_in: expecting more packets (%u/%u)\n", s->bulk_out_pos - 10, ccid_header->dwLength); return; } if (s->bulk_out_pos - 10 !=3D ccid_header->dwLength) { DPRINTF(s, 1, - "usb-ccid: bulk_in: message size mismatch (got %d, expecte= d %d)\n", + "usb-ccid: bulk_in: message size mismatch (got %u, expecte= d %u)\n", s->bulk_out_pos - 10, ccid_header->dwLength); goto err; } @@ -1202,7 +1202,7 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card, ccid_report_error_failed(s, ERROR_HW_ERROR); return; } - DPRINTF(s, 1, "APDU returned to guest %d (answer seq %d, slot %d)\n", + DPRINTF(s, 1, "APDU returned to guest %u (answer seq %d, slot %d)\n", len, answer->seq, answer->slot); ccid_write_data_block_answer(s, apdu, len); } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index aca018d8b5f4..212eb05d3d3c 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1192,7 +1192,7 @@ static int ehci_init_transfer(EHCIPacket *p) =20 while (bytes > 0) { if (cpage > 4) { - fprintf(stderr, "cpage out of range (%d)\n", cpage); + fprintf(stderr, "cpage out of range (%u)\n", cpage); qemu_sglist_destroy(&p->sgl); return -1; } @@ -1598,7 +1598,7 @@ static int ehci_state_fetchentry(EHCIState *ehci, int= async) =20 default: /* TODO: handle FSTN type */ - fprintf(stderr, "FETCHENTRY: entry at %X is of type %d " + fprintf(stderr, "FETCHENTRY: entry at %X is of type %u " "which is not supported yet\n", entry, NLPTR_TYPE_GET(entr= y)); return -1; } --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611337998; cv=none; d=zohomail.com; s=zohoarc; b=exZF4eyrRRFB5WciWc5Bh/wXntZu3rSjqvoxiWocwl9fRSp0qoG0F/goe4Eh1YBFaz/B+h0ZoHW+X5+CI4o7gHMxNa62jt/4UFhaxvwvRcvUC4YI45MZMaO2TQ3GddWbYIyRNS7ON+ZOzRmQE2bqUVeafSRRt4xyOreEHPXqo1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611337998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i5CFxKFH2AAXiXkkyHqdAOwWoxp40benhMXniIxfVcg=; b=Bj/a7gEESsi5ZuxW3RJxUA3BJ3SRYAaphGBabOro8mNmvxOX9H77ywWuLDdrM9bbULlTi4JG3j0jgwA8FCJTNxWTQG1v48hs7WDzEVrWXigiFmSmbzKb/4297+eh9uFJFJi1qy1RAAr+31RL4LVsOdpego7QAdmSZiCbAStooI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611337998039560.3279470463733; Fri, 22 Jan 2021 09:53:18 -0800 (PST) Received: from localhost ([::1]:56050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30cW-00008m-Re for importer@patchew.org; Fri, 22 Jan 2021 12:53:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YU-0003S1-R5 for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YP-0004gD-N3 for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-LxnboqvlMVCyeKb5S0y5UA-1; Fri, 22 Jan 2021 12:48:57 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAD34802B48; Fri, 22 Jan 2021 17:48:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F2F65DA30; Fri, 22 Jan 2021 17:48:51 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 21289180038A; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5CFxKFH2AAXiXkkyHqdAOwWoxp40benhMXniIxfVcg=; b=QjeC12jYm3EJBJUb/PSikflT7I7IhU076xjqgiVLZcq74N9fVecjMG9HKmRn459eb+4awB B5B1b1FLU3ERUv8SIRYcZLl2ixJ9TGUy1pjZzslbJTHA+10hoAGOTqhHsWtsVgUT36BJKq 6SnYnnkoIrLs97nWDnWlwgujKxWJo+Y= X-MC-Unique: LxnboqvlMVCyeKb5S0y5UA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 3/8] hw/usb: Convert to qdev_realize() Date: Fri, 22 Jan 2021 18:48:44 +0100 Message-Id: <20210122174849.3936119-4-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-block@nongnu.org, Markus Armbruster , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Markus Armbruster Device code shouldn't mess with QOM property "realized" since we have proper interfaces (merge commit 6675a653). Commit 8ddab8dd3d "usb/hcd-xhci: Split pci wrapper for xhci base model" and commit f00ff136ee "usb: hcd-xhci-sysbus: Attach xhci to sysbus device" reintroduced two instances. Clean them up. Note that s->xhci is a (bus-less) TYPE_XHCI device. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210119120151.53757-1-armbru@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci-pci.c | 4 +--- hw/usb/hcd-xhci-sysbus.c | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index bba628d3d230..9421734d0fe2 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -115,9 +115,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev,= Error **errp) object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); s->xhci.intr_update =3D xhci_pci_intr_update; s->xhci.intr_raise =3D xhci_pci_intr_raise; - object_property_set_bool(OBJECT(&s->xhci), "realized", true, &err); - if (err) { - error_propagate(errp, err); + if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) { return; } if (strcmp(object_get_typename(OBJECT(dev)), TYPE_NEC_XHCI) =3D=3D 0) { diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c index 29185d2261fb..42e2574c8298 100644 --- a/hw/usb/hcd-xhci-sysbus.c +++ b/hw/usb/hcd-xhci-sysbus.c @@ -33,12 +33,9 @@ void xhci_sysbus_reset(DeviceState *dev) static void xhci_sysbus_realize(DeviceState *dev, Error **errp) { XHCISysbusState *s =3D XHCI_SYSBUS(dev); - Error *err =3D NULL; =20 object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); - object_property_set_bool(OBJECT(&s->xhci), "realized", true, &err); - if (err) { - error_propagate(errp, err); + if (!qdev_realize(DEVICE(&s->xhci), NULL, errp)) { return; } s->irq =3D g_new0(qemu_irq, s->xhci.numintrs); --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611337852; cv=none; d=zohomail.com; s=zohoarc; b=LDEwaS1dM37VSjCbny6e+Vtyw1UfHuvF8dayYBmbgEZMQgLKl7um22y4TUdXENlajnOnou9YYdRnM2w1I7GVqEC7R/uZ+NV7vXaLkuXOGrFyZOFLcd1kUKpll+2MUk8jr1iCkt4xys0lggyLyvwz4aG7h6hRniN3zsdnfEcMkho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611337852; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6z+4q2SdC+4C58JFkyW8FKESFLNToADHL3M9abPRL44=; b=GATIct3ySh6B9XOhUgSz6WUWzX+vquq+bOKChkVAlTGCYL0GJBQufUHEWviFwiODYkRhvzOHK6X4jnTPN4xqqpYpmVji3ahI0dcU0CS26R+Mg+PA96uxnbFGu6eQ35evZs/qwR4uOKwPIuh2uzNCA8UToZ1etpap3z44gifWavY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611337852243573.9326664759709; Fri, 22 Jan 2021 09:50:52 -0800 (PST) Received: from localhost ([::1]:48068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30aB-00058v-5i for importer@patchew.org; Fri, 22 Jan 2021 12:50:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YS-0003Lk-2f for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YO-0004es-2G for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-FunRT4XjNUyxEOYh348zng-1; Fri, 22 Jan 2021 12:48:56 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33B5E1005D4E; Fri, 22 Jan 2021 17:48:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9226F6EF59; Fri, 22 Jan 2021 17:48:51 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2BA2D180038D; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6z+4q2SdC+4C58JFkyW8FKESFLNToADHL3M9abPRL44=; b=LUij0kbdihdvsehc2jDTrVOQ4+xsJr98RZUbJ9iUK8IcI+/8uDRM82bKP5xsJoNMpDoaZj UqpJTUKjtY8vJm4MVFZun6HCIQ/3CErTBN+7MS50Qalx4oQIjVZytVrboI4vC77rpMLkaV sFrpIHwYBPLGafdFfCyXEUKkhHir1qg= X-MC-Unique: FunRT4XjNUyxEOYh348zng-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 4/8] hw/usb/hcd-xhci: Fix extraneous format-truncation error on 32-bit hosts Date: Fri, 22 Jan 2021 18:48:45 +0100 Message-Id: <20210122174849.3936119-5-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 For some reason the assert() added in commit ccb799313a5 ("hw/usb: avoid format truncation warning when formatting port name") does not fix when building with GCC 10. KISS and expand the buffer by 4 bytes to silent the following error when using GCC 10.2.1 on Fedora 33: hw/usb/hcd-xhci.c: In function 'usb_xhci_realize': hw/usb/hcd-xhci.c:3309:54: error: '%d' directive output may be truncated = writing between 1 and 8 bytes into a region of size 5 [-Werror=3Dformat-tru= ncation=3D] 3309 | snprintf(port->name, sizeof(port->name), "usb2 port #= %d", i+1); | ^~~~~~~~~~~~= ~~~ hw/usb/hcd-xhci.c:3309:54: note: directive argument in the range [1, 8947= 8486] In file included from /usr/include/stdio.h:866, from include/qemu/osdep.h:85, from hw/usb/hcd-xhci.c:22: /usr/include/bits/stdio2.h:70:10: note: '__builtin___snprintf_chk' output= between 13 and 20 bytes into a destination of size 16 70 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL = - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~ 71 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hw/usb/hcd-xhci.c:3323:54: error: '%d' directive output may be truncated = writing between 1 and 8 bytes into a region of size 5 [-Werror=3Dformat-tru= ncation=3D] 3323 | snprintf(port->name, sizeof(port->name), "usb3 port #= %d", i+1); | ^~~~~~~~~~~~= ~~~ hw/usb/hcd-xhci.c:3323:54: note: directive argument in the range [1, 8947= 8486] In file included from /usr/include/stdio.h:866, from include/qemu/osdep.h:85, from hw/usb/hcd-xhci.c:22: /usr/include/bits/stdio2.h:70:10: note: '__builtin___snprintf_chk' output= between 13 and 20 bytes into a destination of size 16 70 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL = - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~ 71 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210118181115.313742-1-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index 02ebd764509a..7bba361f3bbd 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -128,7 +128,7 @@ typedef struct XHCIPort { uint32_t portnr; USBPort *uport; uint32_t speedmask; - char name[16]; + char name[20]; MemoryRegion mem; } XHCIPort; =20 --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611338332; cv=none; d=zohomail.com; s=zohoarc; b=Rr2AN1qfdEYSlQneePdYeFFRqLucj8z1ZNXTqMYB8/fp3nHQBBAL0/30bvboatwJb5PBgWapfLZAvnXKRpFp3TiAbVa3UJ4orgS4+lNSun8JU4Jx5XwZTDPIGeC95QReHoYSAdxKxaxfim6Pr4cIrUpwmZaEnax2gRpWWHh74J0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611338332; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j8+wB0NXQC7I8N4RJqXTECBVHlHPFDrvpedg7MR+0qw=; b=fpLQ/4rowW4saVm0rvFplwSyr5xgWbA//19cijZQkVCN9RtY5cZfRckJnsSZlfcHoJG6JGAPrO4vKmsZUfjhLhkG7vWYjFl1YC+CJUUag3hKWDyhGNmMDUufbuQwRPQnnZI/UG2UKzsVF5IuAzwNo5VMBKDoX9I7Qh9/tyvBPmU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611338332252148.97232915152563; Fri, 22 Jan 2021 09:58:52 -0800 (PST) Received: from localhost ([::1]:40536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30hv-0005j6-1g for importer@patchew.org; Fri, 22 Jan 2021 12:58:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YV-0003UW-EM for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YO-0004fE-F0 for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-ON-Np5gMM6GDwGH4cVpy3A-1; Fri, 22 Jan 2021 12:48:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82FA01800D42; Fri, 22 Jan 2021 17:48:56 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 493EE6EF48; Fri, 22 Jan 2021 17:48:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 37CF61800601; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j8+wB0NXQC7I8N4RJqXTECBVHlHPFDrvpedg7MR+0qw=; b=OB+o+UwqzOfRL41pYob3BHt1DiMyFQaQabjVLF5IVLwYEdcpQeCyasNaATWrALc9EVCPJC PR4Gu4JhXgL5F4mkSBaopqWyWgVEnNtpUw6Y85if73khaqTE2k3LSjvDXsyO/aFgxvW4lz 4ZqbF0dJTYZvwzs0WeZH34HXLnzZDDg= X-MC-Unique: ON-Np5gMM6GDwGH4cVpy3A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 5/8] scsi/utils: Add INVALID_PARAM_VALUE sense code definition Date: Fri, 22 Jan 2021 18:48:46 +0100 Message-Id: <20210122174849.3936119-6-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-block@nongnu.org, Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210120153522.1173897-3-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- include/scsi/utils.h | 2 ++ scsi/utils.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/scsi/utils.h b/include/scsi/utils.h index fbc558827993..096489c6cd1e 100644 --- a/include/scsi/utils.h +++ b/include/scsi/utils.h @@ -57,6 +57,8 @@ extern const struct SCSISense sense_code_LBA_OUT_OF_RANGE; extern const struct SCSISense sense_code_INVALID_FIELD; /* Illegal request, Invalid field in parameter list */ extern const struct SCSISense sense_code_INVALID_PARAM; +/* Illegal request, Invalid value in parameter list */ +extern const struct SCSISense sense_code_INVALID_PARAM_VALUE; /* Illegal request, Parameter list length error */ extern const struct SCSISense sense_code_INVALID_PARAM_LEN; /* Illegal request, LUN not supported */ diff --git a/scsi/utils.c b/scsi/utils.c index b37c28301489..793c3a6b9c9a 100644 --- a/scsi/utils.c +++ b/scsi/utils.c @@ -197,6 +197,11 @@ const struct SCSISense sense_code_INVALID_PARAM =3D { .key =3D ILLEGAL_REQUEST, .asc =3D 0x26, .ascq =3D 0x00 }; =20 +/* Illegal request, Invalid value in parameter list */ +const struct SCSISense sense_code_INVALID_PARAM_VALUE =3D { + .key =3D ILLEGAL_REQUEST, .asc =3D 0x26, .ascq =3D 0x01 +}; + /* Illegal request, Parameter list length error */ const struct SCSISense sense_code_INVALID_PARAM_LEN =3D { .key =3D ILLEGAL_REQUEST, .asc =3D 0x1a, .ascq =3D 0x00 --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611337866; cv=none; d=zohomail.com; s=zohoarc; b=iLd7g7NhAY4I8WVS+ai8wCIaLIOmFV42HXzr7NKxSsOXNG6I6ZcUEbJi2ZPAHrnPu+9ggpxkFLj1W8v26FA8akntPI6fwW89aoLPY63O3f3glBQHMP8v9cIk/BgdJeWlmwQyK8zDC3b2bK5Dh16UnYCy20RmWQGKWUYeNbr9bNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611337866; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3cYJqJSxpRfhdfFzwRR6c0uMoYnqDQRDW/OpcLay+J4=; b=C5xsf4FzKnfoCv7P0701/o/xqVUugl/xir7OzBuuMgF72g65R1pGNZo3YzGz724VaqBcRHzCZP8NK8dAABM02lKs0HJWiluhkt3ENWvLgO2v907z2HIqTN5Hsfe/CFFj78a5gATFqNzOI+cHY1mlSqjZ/W+fBzxjt3KB7a3VsMI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611337866814906.9376136134283; Fri, 22 Jan 2021 09:51:06 -0800 (PST) Received: from localhost ([::1]:49290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30aP-0005fw-QA for importer@patchew.org; Fri, 22 Jan 2021 12:51:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YX-0003ZV-BN for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YV-0004iK-4N for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-9HB-n-beP0GBOdq-vfxBQg-1; Fri, 22 Jan 2021 12:49:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B50C7802B40; Fri, 22 Jan 2021 17:48:59 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AE2E2BFE9; Fri, 22 Jan 2021 17:48:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 42B73180062C; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cYJqJSxpRfhdfFzwRR6c0uMoYnqDQRDW/OpcLay+J4=; b=MpONTscnKaYo+8beHM/9sQj43ShPEoATtG8XRdPsr/+qmURYP+v4+vFWuWswIaqZmInEPh 4eGdBM24Nz1keO7z3vqRh+UMO32Xsxq7EjBsBwMADqOSY04fnxxA2yW/Pn74UHvr/6hycr zOeEOcdaeyWLxHxFOugzorJylpWQmts= X-MC-Unique: 9HB-n-beP0GBOdq-vfxBQg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 6/8] hw/usb/dev-uas: Report command additional adb length as unsupported Date: Fri, 22 Jan 2021 18:48:47 +0100 Message-Id: <20210122174849.3936119-7-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Ed Maste , qemu-block@nongnu.org, Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Daniele Buono , Han Han Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 We are not ready to handle additional CDB data. If a guest sends a packet with such additional data, report the command parameter as not supported. Specify a size (of 1 byte) for the add_cdb member we are not using, to fix the following warning: usb/dev-uas.c:157:31: error: field 'status' with variable sized type 'uas= _iu' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-= variable-sized-type-not-at-end] uas_iu status; ^ Reported-by: Ed Maste Reported-by: Daniele Buono Reported-by: Han Han Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210120153522.1173897-4-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-uas.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index cec071d96c49..a51402bc0bfd 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/log.h" =20 #include "hw/usb.h" #include "migration/vmstate.h" @@ -70,7 +71,7 @@ typedef struct { uint8_t reserved_2; uint64_t lun; uint8_t cdb[16]; - uint8_t add_cdb[]; + uint8_t add_cdb[1]; /* not supported by QEMU */ } QEMU_PACKED uas_iu_command; =20 typedef struct { @@ -700,6 +701,11 @@ static void usb_uas_command(UASDevice *uas, uas_iu *iu) uint32_t len; uint16_t tag =3D be16_to_cpu(iu->hdr.tag); =20 + if (iu->command.add_cdb_length > 0) { + qemu_log_mask(LOG_UNIMP, "additional adb length not yet supported\= n"); + goto unsupported_len; + } + if (uas_using_streams(uas) && tag > UAS_MAX_STREAMS) { goto invalid_tag; } @@ -735,6 +741,10 @@ static void usb_uas_command(UASDevice *uas, uas_iu *iu) } return; =20 +unsupported_len: + usb_uas_queue_fake_sense(uas, tag, sense_code_INVALID_PARAM_VALUE); + return; + invalid_tag: usb_uas_queue_fake_sense(uas, tag, sense_code_INVALID_TAG); return; --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611338182; cv=none; d=zohomail.com; s=zohoarc; b=YqXudUSJ5MJne4f4j2HqStp4nBZFn6N6mGHeaAOSallP31p8ZktBmsE1CWiMDKoFCbPWGlo6eYdS77AZV//+v7oAbhTY0rgkOmq5muOwM8dxDG2SYamHIW3D1uk9v2ZFYrlOX1cu2OTDojQZ34b9i3sgyioTctAh6YoUCL/sPWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611338182; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MU9L3KBjHy7E33bhB7dlw3wAVpvK58mBVxYhFviXHW8=; b=WIc1qvkwU0cOd6WgQ6LvR94tanPvPMlf0x3loXtAkN/BBsJebeaeoU+uUlNqczju3L/1f83ur6XDWE47fASvY1evdR93dOjLMXwMxDftNgI/0ajWU6ql5Bk0ti4yceJteiMy2IKPWt6ufyHMIJI0ZxxJZ2sy8NMc4LI0CR5faa0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611338182950681.5882832487887; Fri, 22 Jan 2021 09:56:22 -0800 (PST) Received: from localhost ([::1]:35850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30fV-0003at-So for importer@patchew.org; Fri, 22 Jan 2021 12:56:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YY-0003dE-GI for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YS-0004ho-Mg for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-wi8mv1fTM-66HPV2L1oH8g-1; Fri, 22 Jan 2021 12:49:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10EF480666F; Fri, 22 Jan 2021 17:49:00 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BC9D60C13; Fri, 22 Jan 2021 17:48:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 56903180062D; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MU9L3KBjHy7E33bhB7dlw3wAVpvK58mBVxYhFviXHW8=; b=FJThOM+uGpbWLT/rItUp+V6wn86/SqQNbXoOlk4a53x1WBntLYyOn7tw2v9AWE3+/9VoiT pDbcSnO+aXHMpfODIvXsvssBv7cdD0nErJLvd2gxCGu/IGGvzJJZcGhRgF1oxYD4dD5qVe /OkSaiB8N/a03Rj0k2nieSScwURVMu4= X-MC-Unique: wi8mv1fTM-66HPV2L1oH8g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 7/8] usb: add pcap support. Date: Fri, 22 Jan 2021 18:48:48 +0100 Message-Id: <20210122174849.3936119-8-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Log all traffic of a specific usb device to a pcap file for later inspection. File format is compatible with linux usb monitor. Usage: qemu -device usb-${somedevice},pcap=3Dfile.pcap wireshark file.pcap Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210119194452.2148048-1-kraxel@redhat.com> Signed-off-by: Gerd Hoffmann --- include/hw/usb.h | 8 ++ hw/usb/bus.c | 16 +++ hw/usb/core.c | 17 +++ hw/usb/pcap.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ hw/usb/meson.build | 1 + 5 files changed, 293 insertions(+) create mode 100644 hw/usb/pcap.c diff --git a/include/hw/usb.h b/include/hw/usb.h index a70a72e9177a..abfbfc5284c2 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -231,6 +231,9 @@ struct USBDevice { void *opaque; uint32_t flags; =20 + char *pcap_filename; + FILE *pcap; + /* Actual connected speed */ int speed; /* Supported speeds, not in info because it may be variable (hostdevs)= */ @@ -570,4 +573,9 @@ int usb_get_quirks(uint16_t vendor_id, uint16_t product= _id, uint8_t interface_class, uint8_t interface_subclass, uint8_t interface_protocol); =20 +/* pcap.c */ +void usb_pcap_init(FILE *fp); +void usb_pcap_ctrl(USBPacket *p, bool setup); +void usb_pcap_data(USBPacket *p, bool setup); + #endif diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 2b1104145157..064f94e9c3cc 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -23,6 +23,7 @@ static Property usb_props[] =3D { USB_DEV_FLAG_FULL_PATH, true), DEFINE_PROP_BIT("msos-desc", USBDevice, flags, USB_DEV_FLAG_MSOS_DESC_ENABLE, true), + DEFINE_PROP_STRING("pcap", USBDevice, pcap_filename), DEFINE_PROP_END_OF_LIST() }; =20 @@ -270,6 +271,17 @@ static void usb_qdev_realize(DeviceState *qdev, Error = **errp) return; } } + + if (dev->pcap_filename) { + int fd =3D qemu_open_old(dev->pcap_filename, O_CREAT | O_WRONLY | = O_TRUNC, 0666); + if (fd < 0) { + error_setg(errp, "open %s failed", dev->pcap_filename); + usb_qdev_unrealize(qdev); + return; + } + dev->pcap =3D fdopen(fd, "w"); + usb_pcap_init(dev->pcap); + } } =20 static void usb_qdev_unrealize(DeviceState *qdev) @@ -283,6 +295,10 @@ static void usb_qdev_unrealize(DeviceState *qdev) g_free(s); } =20 + if (dev->pcap) { + fclose(dev->pcap); + } + if (dev->attached) { usb_device_detach(dev); } diff --git a/hw/usb/core.c b/hw/usb/core.c index c895522a1d5d..975f76250a1a 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -154,6 +154,7 @@ static void do_token_setup(USBDevice *s, USBPacket *p) index =3D (s->setup_buf[5] << 8) | s->setup_buf[4]; =20 if (s->setup_buf[0] & USB_DIR_IN) { + usb_pcap_ctrl(p, true); usb_device_handle_control(s, p, request, value, index, s->setup_len, s->data_buf); if (p->status =3D=3D USB_RET_ASYNC) { @@ -190,6 +191,7 @@ static void do_token_in(USBDevice *s, USBPacket *p) switch(s->setup_state) { case SETUP_STATE_ACK: if (!(s->setup_buf[0] & USB_DIR_IN)) { + usb_pcap_ctrl(p, true); usb_device_handle_control(s, p, request, value, index, s->setup_len, s->data_buf); if (p->status =3D=3D USB_RET_ASYNC) { @@ -197,6 +199,7 @@ static void do_token_in(USBDevice *s, USBPacket *p) } s->setup_state =3D SETUP_STATE_IDLE; p->actual_length =3D 0; + usb_pcap_ctrl(p, false); } break; =20 @@ -215,6 +218,7 @@ static void do_token_in(USBDevice *s, USBPacket *p) } s->setup_state =3D SETUP_STATE_IDLE; p->status =3D USB_RET_STALL; + usb_pcap_ctrl(p, false); break; =20 default: @@ -230,6 +234,7 @@ static void do_token_out(USBDevice *s, USBPacket *p) case SETUP_STATE_ACK: if (s->setup_buf[0] & USB_DIR_IN) { s->setup_state =3D SETUP_STATE_IDLE; + usb_pcap_ctrl(p, false); /* transfer OK */ } else { /* ignore additional output */ @@ -251,6 +256,7 @@ static void do_token_out(USBDevice *s, USBPacket *p) } s->setup_state =3D SETUP_STATE_IDLE; p->status =3D USB_RET_STALL; + usb_pcap_ctrl(p, false); break; =20 default: @@ -288,6 +294,7 @@ static void do_parameter(USBDevice *s, USBPacket *p) usb_packet_copy(p, s->data_buf, s->setup_len); } =20 + usb_pcap_ctrl(p, true); usb_device_handle_control(s, p, request, value, index, s->setup_len, s->data_buf); if (p->status =3D=3D USB_RET_ASYNC) { @@ -301,6 +308,7 @@ static void do_parameter(USBDevice *s, USBPacket *p) p->actual_length =3D 0; usb_packet_copy(p, s->data_buf, s->setup_len); } + usb_pcap_ctrl(p, false); } =20 /* ctrl complete function for devices which use usb_generic_handle_packet = and @@ -311,6 +319,7 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBP= acket *p) { if (p->status < 0) { s->setup_state =3D SETUP_STATE_IDLE; + usb_pcap_ctrl(p, false); } =20 switch (s->setup_state) { @@ -325,6 +334,7 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBP= acket *p) case SETUP_STATE_ACK: s->setup_state =3D SETUP_STATE_IDLE; p->actual_length =3D 0; + usb_pcap_ctrl(p, false); break; =20 case SETUP_STATE_PARAM: @@ -359,12 +369,14 @@ USBDevice *usb_find_device(USBPort *port, uint8_t add= r) static void usb_process_one(USBPacket *p) { USBDevice *dev =3D p->ep->dev; + bool nak; =20 /* * Handlers expect status to be initialized to USB_RET_SUCCESS, but it * can be USB_RET_NAK here from a previous usb_process_one() call, * or USB_RET_ASYNC from going through usb_queue_one(). */ + nak =3D (p->status =3D=3D USB_RET_NAK); p->status =3D USB_RET_SUCCESS; =20 if (p->ep->nr =3D=3D 0) { @@ -388,6 +400,9 @@ static void usb_process_one(USBPacket *p) } } else { /* data pipe */ + if (!nak) { + usb_pcap_data(p, true); + } usb_device_handle_data(dev, p); } } @@ -439,6 +454,7 @@ void usb_handle_packet(USBDevice *dev, USBPacket *p) assert(p->stream || !p->ep->pipeline || QTAILQ_EMPTY(&p->ep->queue)); if (p->status !=3D USB_RET_NAK) { + usb_pcap_data(p, false); usb_packet_set_state(p, USB_PACKET_COMPLETE); } } @@ -458,6 +474,7 @@ void usb_packet_complete_one(USBDevice *dev, USBPacket = *p) (p->short_not_ok && (p->actual_length < p->iov.size))) { ep->halted =3D true; } + usb_pcap_data(p, false); usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); dev->port->ops->complete(dev->port, p); diff --git a/hw/usb/pcap.c b/hw/usb/pcap.c new file mode 100644 index 000000000000..4350989d3a71 --- /dev/null +++ b/hw/usb/pcap.c @@ -0,0 +1,251 @@ +/* + * usb packet capture + * + * Copyright (c) 2021 Gerd Hoffmann + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/usb.h" + +#define PCAP_MAGIC 0xa1b2c3d4 +#define PCAP_MAJOR 2 +#define PCAP_MINOR 4 + +/* https://wiki.wireshark.org/Development/LibpcapFileFormat */ + +struct pcap_hdr { + uint32_t magic_number; /* magic number */ + uint16_t version_major; /* major version number */ + uint16_t version_minor; /* minor version number */ + int32_t thiszone; /* GMT to local correction */ + uint32_t sigfigs; /* accuracy of timestamps */ + uint32_t snaplen; /* max length of captured packets, in octets = */ + uint32_t network; /* data link type */ +}; + +struct pcaprec_hdr { + uint32_t ts_sec; /* timestamp seconds */ + uint32_t ts_usec; /* timestamp microseconds */ + uint32_t incl_len; /* number of octets of packet saved in file */ + uint32_t orig_len; /* actual length of packet */ +}; + +/* https://www.tcpdump.org/linktypes.html */ +/* linux: Documentation/usb/usbmon.rst */ +/* linux: drivers/usb/mon/mon_bin.c */ + +#define LINKTYPE_USB_LINUX 189 /* first 48 bytes only */ +#define LINKTYPE_USB_LINUX_MMAPPED 220 /* full 64 byte header */ + +struct usbmon_packet { + uint64_t id; /* 0: URB ID - from submission to callback */ + unsigned char type; /* 8: Same as text; extensible. */ + unsigned char xfer_type; /* ISO (0), Intr, Control, Bulk (3) */ + unsigned char epnum; /* Endpoint number and transfer direction= */ + unsigned char devnum; /* Device address */ + uint16_t busnum; /* 12: Bus number */ + char flag_setup; /* 14: Same as text */ + char flag_data; /* 15: Same as text; Binary zero is OK. */ + int64_t ts_sec; /* 16: gettimeofday */ + int32_t ts_usec; /* 24: gettimeofday */ + int32_t status; /* 28: */ + unsigned int length; /* 32: Length of data (submitted or actual) */ + unsigned int len_cap; /* 36: Delivered length */ + union { /* 40: */ + unsigned char setup[8]; /* Only for Control S-type */ + struct iso_rec { /* Only for ISO */ + int32_t error_count; + int32_t numdesc; + } iso; + } s; + int32_t interval; /* 48: Only for Interrupt and ISO */ + int32_t start_frame; /* 52: For ISO */ + uint32_t xfer_flags; /* 56: copy of URB's transfer_flags */ + uint32_t ndesc; /* 60: Actual number of ISO descriptors */ +}; /* 64 total length */ + +/* -----------------------------------------------------------------------= - */ + +#define CTRL_LEN 4096 +#define DATA_LEN 256 + +static int usbmon_status(USBPacket *p) +{ + switch (p->status) { + case USB_RET_SUCCESS: + return 0; + case USB_RET_NODEV: + return -19; /* -ENODEV */ + default: + return -121; /* -EREMOTEIO */ + } +} + +static unsigned int usbmon_epnum(USBPacket *p) +{ + unsigned epnum =3D 0; + + epnum |=3D p->ep->nr; + epnum |=3D (p->pid =3D=3D USB_TOKEN_IN) ? 0x80 : 0; + return epnum; +} + +static unsigned char usbmon_xfer_type[] =3D { + [USB_ENDPOINT_XFER_CONTROL] =3D 2, + [USB_ENDPOINT_XFER_ISOC] =3D 0, + [USB_ENDPOINT_XFER_BULK] =3D 3, + [USB_ENDPOINT_XFER_INT] =3D 1, +}; + +static void do_usb_pcap_header(FILE *fp, struct usbmon_packet *packet) +{ + struct pcaprec_hdr header; + struct timeval tv; + + gettimeofday(&tv, NULL); + packet->ts_sec =3D tv.tv_sec; + packet->ts_usec =3D tv.tv_usec; + + header.ts_sec =3D packet->ts_sec; + header.ts_usec =3D packet->ts_usec; + header.incl_len =3D packet->len_cap; + header.orig_len =3D packet->length + sizeof(*packet); + fwrite(&header, sizeof(header), 1, fp); + fwrite(packet, sizeof(*packet), 1, fp); +} + +static void do_usb_pcap_ctrl(FILE *fp, USBPacket *p, bool setup) +{ + USBDevice *dev =3D p->ep->dev; + bool in =3D dev->setup_buf[0] & USB_DIR_IN; + struct usbmon_packet packet =3D { + .id =3D 0, + .type =3D setup ? 'S' : 'C', + .xfer_type =3D usbmon_xfer_type[USB_ENDPOINT_XFER_CONTROL], + .epnum =3D in ? 0x80 : 0, + .devnum =3D dev->addr, + .flag_data =3D '=3D', + .length =3D dev->setup_len, + }; + int data_len =3D dev->setup_len; + + if (data_len > CTRL_LEN) { + data_len =3D CTRL_LEN; + } + if (setup) { + memcpy(packet.s.setup, dev->setup_buf, 8); + } else { + packet.status =3D usbmon_status(p); + } + + if (in && setup) { + packet.flag_data =3D '<'; + packet.length =3D 0; + data_len =3D 0; + } + if (!in && !setup) { + packet.flag_data =3D '>'; + packet.length =3D 0; + data_len =3D 0; + } + + packet.len_cap =3D data_len + sizeof(packet); + do_usb_pcap_header(fp, &packet); + if (data_len) { + fwrite(dev->data_buf, data_len, 1, fp); + } + + fflush(fp); +} + +static void do_usb_pcap_data(FILE *fp, USBPacket *p, bool setup) +{ + struct usbmon_packet packet =3D { + .id =3D p->id, + .type =3D setup ? 'S' : 'C', + .xfer_type =3D usbmon_xfer_type[p->ep->type], + .epnum =3D usbmon_epnum(p), + .devnum =3D p->ep->dev->addr, + .flag_data =3D '=3D', + .length =3D p->iov.size, + }; + int data_len =3D p->iov.size; + + if (p->ep->nr =3D=3D 0) { + /* ignore control pipe packets */ + return; + } + + if (data_len > DATA_LEN) { + data_len =3D DATA_LEN; + } + if (!setup) { + packet.status =3D usbmon_status(p); + if (packet.length > p->actual_length) { + packet.length =3D p->actual_length; + } + if (data_len > p->actual_length) { + data_len =3D p->actual_length; + } + } + + if (p->pid =3D=3D USB_TOKEN_IN && setup) { + packet.flag_data =3D '<'; + packet.length =3D 0; + data_len =3D 0; + } + if (p->pid =3D=3D USB_TOKEN_OUT && !setup) { + packet.flag_data =3D '>'; + packet.length =3D 0; + data_len =3D 0; + } + + packet.len_cap =3D data_len + sizeof(packet); + do_usb_pcap_header(fp, &packet); + if (data_len) { + void *buf =3D g_malloc(data_len); + iov_to_buf(p->iov.iov, p->iov.niov, 0, buf, data_len); + fwrite(buf, data_len, 1, fp); + g_free(buf); + } + + fflush(fp); +} + +void usb_pcap_init(FILE *fp) +{ + struct pcap_hdr header =3D { + .magic_number =3D PCAP_MAGIC, + .version_major =3D 2, + .version_minor =3D 4, + .snaplen =3D MAX(CTRL_LEN, DATA_LEN) + sizeof(struct usbmon_= packet), + .network =3D LINKTYPE_USB_LINUX_MMAPPED, + }; + + fwrite(&header, sizeof(header), 1, fp); +} + +void usb_pcap_ctrl(USBPacket *p, bool setup) +{ + FILE *fp =3D p->ep->dev->pcap; + + if (!fp) { + return; + } + + do_usb_pcap_ctrl(fp, p, setup); +} + +void usb_pcap_data(USBPacket *p, bool setup) +{ + FILE *fp =3D p->ep->dev->pcap; + + if (!fp) { + return; + } + + do_usb_pcap_data(fp, p, setup); +} diff --git a/hw/usb/meson.build b/hw/usb/meson.build index f46c6b665535..653192cff6fa 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -5,6 +5,7 @@ softmmu_ss.add(files( 'bus.c', 'combined-packet.c', 'core.c', + 'pcap.c', 'libhw.c' )) =20 --=20 2.29.2 From nobody Mon Feb 9 10:49:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611337972; cv=none; d=zohomail.com; s=zohoarc; b=i8nsqtaCGak7JFiIq5za+xmvdzZYJpO0UA+UVn8+SinHMTvYC4A8lOGvyDRwuAoi/sodzngxrrYUiM72hbRsChmoCmo5r96OapZyoYihXkpsIyrwd1d9Q69dTLlGJfL+/drlcjUUXAvWFAblJGN2rc2P79o9qiElFHMJOYMqbpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611337972; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5N1EjzAm0Y7IDgRdCgj3PqwoKZeQzrmVWoaxscKEfdI=; b=MBRwpT++hocdTdZHMuXw8BMuQS4fiUWODUGVUI92xwXwDvZxY61FAFXluHVW/QCo/sJ4Sa16dcj6QWwOf51wT8kNOEfnxsnT5rsOVmyKWqDF2F0Yj67HROeCUjF66rLBrWqhGVumVB+6G8L0aUsIf2HNFiGgKx9XXV30gkyUMQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611337972111310.99554254650013; Fri, 22 Jan 2021 09:52:52 -0800 (PST) Received: from localhost ([::1]:54284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l30c6-0007sj-N9 for importer@patchew.org; Fri, 22 Jan 2021 12:52:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l30YV-0003Vo-UB for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l30YR-0004gZ-Ea for qemu-devel@nongnu.org; Fri, 22 Jan 2021 12:49:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-04fJ7T_4NIaQ9Zg9fjtK9A-1; Fri, 22 Jan 2021 12:49:00 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B20FF180A099; Fri, 22 Jan 2021 17:48:59 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-182.ams2.redhat.com [10.36.112.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CEA919C59; Fri, 22 Jan 2021 17:48:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 611D9180062E; Fri, 22 Jan 2021 18:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611337742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5N1EjzAm0Y7IDgRdCgj3PqwoKZeQzrmVWoaxscKEfdI=; b=c4yq4Z0GMKgP3gQtRecUEyX76r1pv1myP8+/4IYVkNj+5EIsNonwyA+puoGqXC6b8dccxA eyBGWjzDVfk44BHyczX6MWkJWWygMh+gdJ2HInrDRo/IPYe6+olOo/aBnaoZZSzHlDMB3Y CNoyCovL+MsmDj3M/U6V4HlTpdx4R5Q= X-MC-Unique: 04fJ7T_4NIaQ9Zg9fjtK9A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 8/8] usb-host: map LIBUSB_SPEED_SUPER_PLUS to USB_SPEED_SUPER Date: Fri, 22 Jan 2021 18:48:49 +0100 Message-Id: <20210122174849.3936119-9-kraxel@redhat.com> In-Reply-To: <20210122174849.3936119-1-kraxel@redhat.com> References: <20210122174849.3936119-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.182, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Paolo Bonzini , Angel Pagan , Gerd Hoffmann , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Handle host superspeedplus (usb 3.1+) devices like superspeed (usb 3.0) devices. That is enough to get them handled properly by xhci. They show up as superspeed devices inside the guest, but should be able to actually run at higher speeds. Reported-by: Angel Pagan Tested-by: Angel Pagan Signed-off-by: Gerd Hoffmann Message-Id: <20210121150832.3564097-1-kraxel@redhat.com> --- hw/usb/host-libusb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 295d20227ad3..7dde3d12069e 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -179,6 +179,9 @@ static void usb_host_attach_kernel(USBHostDevice *s); #if LIBUSB_API_VERSION >=3D 0x01000103 # define HAVE_STREAMS 1 #endif +#if LIBUSB_API_VERSION >=3D 0x01000106 +# define HAVE_SUPER_PLUS 1 +#endif =20 static const char *speed_name[] =3D { [LIBUSB_SPEED_UNKNOWN] =3D "?", @@ -186,6 +189,9 @@ static const char *speed_name[] =3D { [LIBUSB_SPEED_FULL] =3D "12", [LIBUSB_SPEED_HIGH] =3D "480", [LIBUSB_SPEED_SUPER] =3D "5000", +#ifdef HAVE_SUPER_PLUS + [LIBUSB_SPEED_SUPER_PLUS] =3D "5000+", +#endif }; =20 static const unsigned int speed_map[] =3D { @@ -193,6 +199,9 @@ static const unsigned int speed_map[] =3D { [LIBUSB_SPEED_FULL] =3D USB_SPEED_FULL, [LIBUSB_SPEED_HIGH] =3D USB_SPEED_HIGH, [LIBUSB_SPEED_SUPER] =3D USB_SPEED_SUPER, +#ifdef HAVE_SUPER_PLUS + [LIBUSB_SPEED_SUPER_PLUS] =3D USB_SPEED_SUPER, +#endif }; =20 static const unsigned int status_map[] =3D { @@ -964,8 +973,14 @@ static int usb_host_open(USBHostDevice *s, libusb_devi= ce *dev, int hostfd) libusb_speed =3D LIBUSB_SPEED_HIGH; break; case 5: /* super */ + libusb_speed =3D LIBUSB_SPEED_SUPER; + break; case 6: /* super plus */ +#ifdef HAVE_SUPER_PLUS + libusb_speed =3D LIBUSB_SPEED_SUPER_PLUS; +#else libusb_speed =3D LIBUSB_SPEED_SUPER; +#endif break; } } --=20 2.29.2