From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a1122186f3-ffe9142a-9b0f-4dd3-a56d-b8b918f31986-000000@eu-central-1.amazonses.com> Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11023110.outbound.protection.outlook.com [40.107.159.110]) by lore.virtuozzo.com (Postfix) with ESMTPS id EADFE802A7 for ; Tue, 6 Oct 2026 16:52:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V3VPRuFXybziWUWuPg7Yvr00YSdxNow673ws67pbecJJ7NHownddLPi/0BHQGqNGDaS99+MtZh+H4apWCV5KEUGPWAXvMIt7iiD0RpNfo5p5rsn7kQcMqOJECmxaGhDTpJ6GaDCUw+SIOaUEaiPCr3soAWpY6P/81jGJjAtrBiq9GgLEhJKzB8LFUs+eENfGWhbGHWfAJUlLgJbtRWAKFg0zt3jdxsqGqMQ46J9L4A+TfIAnWW+7GrvdjCJprEGwmqXsjc7BxIPm7NvQ4BxHAWc8mW/Hp01IRcQdFKT49CZj1E7TtwNTbqbjSSQ89B8CJ4d3/zSAPNObyt+MSicgxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jUQagHcVURNGZW4jQW84acZAssd+Y6ur423dhqFb2K0=; b=OYD71t5lQnxqUeV2csiYgh66WinTKVD5p0ABuNSaNr8S46g1My1h+DZ9yzn2JpmG9ax/Tt5ZxBGfIpbNJjxhllrlZXthnqNx2zoevjk63RXCbUSxqEv5dN3z/1OjxaoDP1lx8uG8Wwrd/vnE41iKdMdl7xrIzSt4/pW/Oe33asTLnNP0k6dmccRQXuctFmLmUyQ84lub21lvDAF86TdDWCLiw6xanPdt4w7awT9+GZjkoA+Ew4aOIWEF99df11RXwaXEz2y4Po396Gi13sRntDftEYTYByEsHqvgl4pcI5hFhTXB3yyjNPHV6AX9cdOqoDqooEJ6630JUo2Rl+FD3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.6) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=eu-central-1.amazonses.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=amazonses.com; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jUQagHcVURNGZW4jQW84acZAssd+Y6ur423dhqFb2K0=; b=Zt2/cwPvJNtKrHNcbZr1P+ezV/P+C7AP6AcIQDQo+tlaJGacq4HjRyxJ0OwQH6JNc3h1IqipceqEYjXsORgd06cZQhblxyDC5ysxJHv8RWvqO5XK+ZpvhvZWKfpYT/fdjwtdIfpWk/DVvqjzJsmIyUXAA3nfgTMOVn8zT74JaB4= Received: from MA3P292CA0072.ESPP292.PROD.OUTLOOK.COM (2603:10a6:250:49::17) by PAXPR08MB6430.eurprd08.prod.outlook.com (2603:10a6:102:156::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.15; Tue, 6 Oct 2026 16:52:30 +0000 Received: from MAD0EPF000008AC.eurprd04.prod.outlook.com (2603:10a6:250:49:cafe::a8) by MA3P292CA0072.outlook.office365.com (2603:10a6:250:49::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.5 via Frontend Transport; Tue, 6 Oct 2026 16:52:30 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.6) smtp.mailfrom=eu-central-1.amazonses.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com;dkim=pass (signature was verified) header.d=amazonses.com;dmarc=pass action=none header.from=sashiko.virtuozzo.com; Received-SPF: Pass (protection.outlook.com: domain of eu-central-1.amazonses.com designates 69.169.224.6 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.6; helo=b224-6.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-6.smtp-out.eu-central-1.amazonses.com (69.169.224.6) by MAD0EPF000008AC.mail.protection.outlook.com (10.167.241.185) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.496.14 via Frontend Transport; Tue, 6 Oct 2026 16:52:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1791305549; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Message-ID; bh=TS/NrDRiFL2bbwV5WkExqcV2AdrpQwUH6CalofaF3PY=; b=0HW/8YuunGQY1zJn5RH2Px05QEP4C/0ADfZixQVHqp7xVLqGei0/vAdqEF9yj9H5 52/2aBNdZjDAp1o3MH83D/1l+ePIAmjCgLBLn6yF0CY2RyOea3PIeSnICD4OjrlnsdS hOA4fu4tPvs+997zvFZ6eGzXS0t9/stGTNNwpUaJfRTUb4uIXm9NthR5szRS3jZsVb2 7n9G3PSuK+SE5mJhyAKJH+4xKB6Swja0Da9HQSNfGDZ66flO1VPxzGKmOY7d5DPAE+l 84DtL5Dxlo+1DiJ0ftJVuq7Hpc8tQ+Cr/wP1p2dJjM5VTQytlBumTDTLldNpIF4cecS baHMqthXqQ== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=sokbgaaqhfgd6qjht2wmdajpuuanpimv; d=amazonses.com; t=1791305549; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Message-ID:Feedback-ID; bh=TS/NrDRiFL2bbwV5WkExqcV2AdrpQwUH6CalofaF3PY=; b=kQ64TD2bqoLWR9Gu0S7aRKs1MrhTC0uVidpYzxr/EXp12GGxZGs/HtqXUPpkAzuD Q1nT41YTppdjx18FsSmEbTX6w7GS5cJrWQXD15Q3MVG1mCgSryjkiSECOmfjMpL9GIq BIWoJj2eBWSFXfgoXeO3BlsLanabrTbmGTGgrD3Y= From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH QEMU HCI-8.0 v8 12/14] usb-host: reconfigure endpoints on CPR incoming #VSTOR-137800 To: Andrey Drobyshev , svt-core@virtuozzo.com Cc: andrey.drobyshev@virtuozzo.com, den@openvz.org In-Reply-To: <20261006-usb-host_v3-v8-12-72ae4fb8977b@virtuozzo.com> References: <20261006-usb-host_v3-v8-0-72ae4fb8977b@virtuozzo.com> <20261006-usb-host_v3-v8-12-72ae4fb8977b@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 6 Oct 2026 16:52:29 +0000 Message-ID: <010701a1122186f3-ffe9142a-9b0f-4dd3-a56d-b8b918f31986-000000@eu-central-1.amazonses.com> Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.10.06-69.169.224.6 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MAD0EPF000008AC:EE_|PAXPR08MB6430:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 2f156bc7-3b69-453b-44a4-08df23ca35be X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|9140799003|32142699015|61400799027|48200799018|13003099007|55112099003|4143699003|22082099003|16102099003|18002099003|5113699003|6133799003|4113699003|10067099003|5023799004|5063699009|56012099006; X-Microsoft-Antispam-Message-Info: mX8ShwJJsjdW6BhyXX3Sn5PEtCkNJ2he5+N3u6GQIuKtfh+jMWBNguNKDNEMbnsyOc48IqbXSrlkmva2oQnn13SEXESNqm6IRJIEw3AXH8JqGOxMDxPz6qsfAw3UMHJ8LMgwX2O0PPnD1eJTNgUfGYJtckF4+4oBkOjNhpUTs8MKk5kr0Qz1s2J0V0xHnpESeViGtGshSZXjvxMW8uQvglt/Uiuq4c4tsvkzp4wY8YCYOVAyhsGIsBO6lMzb+JckK1TsuHZ65jmRbt/Th0NQqrwwevGmXQEp5WPdMgqeAkEjL0El80Qc2D32KH06enep8TVWlQyu8FayVzq3Y75Gt0o60Saiqocqxmek9XXEVpWq69wSLWKoJ6PZcsInghHT3i5UzWn1XzcnxUrzQMBFIc1KZN2dRzYMYKok4vsl13PiNiymxbQQmi7V3BkMc7lwazG4R9CM5slQRpep9hzW9mdsi4+1QIoswZqRXOlcxRdM9kRjL3wcPrM9CN6+JINtUpaLNEJxPGg+jWyy9fog6fxeeCWohH/wRCWIs0vRm7YrFzrmpFG7ShgTn/RMihjnKx4ThnbOM/7SwWnhlY+6ZInJOkR+5dRDOc+37emBCbx+EpejqEhU+JT9w6gZjKEH+QUo3v3EzpeN060atLwOY4R0xYl34fEgzqWzhJNiB8FXstPFti/iJrz6ZsDIVpEyDG9a3TtzbR20pehUR+GkS0QIerjWt5ER9bWScIwNc9+6BRKU1VaX1/hasCimTdekpjoaqwnsT5s30KJI8RlM06+InczeEtko0CWx2WTg5AEO5iSN0Fs+NnkHdQo0fffX X-Forefront-Antispam-Report: CIP:69.169.224.6;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-6.smtp-out.eu-central-1.amazonses.com;PTR:b224-6.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(376014)(9140799003)(32142699015)(61400799027)(48200799018)(13003099007)(55112099003)(4143699003)(22082099003)(16102099003)(18002099003)(5113699003)(6133799003)(4113699003)(10067099003)(5023799004)(5063699009)(56012099006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dN9qjA/xX4H+m5a/9xa1yzNJfbqpdGCUnGeV/S4yiDVFGs+spd+O2RDhgQPSmxpviKwJG23WxB1/Pmc04zd6j8dpkwOdKv+Rkjsq6KqA+u+uxYUmSLrt+cwLJv3PBlAou5/K1UroMQgdVOpxTmgKGSt/UGDcxKo2jCgInv/DQAnhZ7vvVXT2zvSykUy/xFW2jANY1M2cX0zoGu9MgB8b7z2nBVDw81BIUPkY+Ndm0MG+owHxvEHaRXdw4nVYBwpItX9PD+rwfSInanMfBrUPrGXwKjvtBF2RYNoIsEflvRkOpKedeuMCG61QqVjUJ36wkhu/rdOo/2R8Wn0FTjwvZOfpHj0P+0H5d7NiLISnVRoLgdyafZnY3SlNbZiT+vZwsbuBMl+Yq0WolHClTgwTe1JYIwizSaIwe2Qx3djF+uWFRtn51/zFECCbiTTJwAaX X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2026 16:52:30.0997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f156bc7-3b69-453b-44a4-08df23ca35be X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: MAD0EPF000008AC.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6430 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Low] usb-host: CPR reclaim claims interfaces and sets configuration for = guests that never configured the device -- commit 4d875277381be99a72691b7786690c4fc8a9ce77 Author: Andrey Drobyshev usb-host: reconfigure endpoints on CPR incoming #VSTOR-137800 On CPR incoming, this patch rebuilds the libusb endpoints with usb_host_ep_update(). It also adds usb_host_cpr_reclaim_interfaces(), which re-claims interfaces so that libusb's handle matches the preserved fd. > diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c > --- a/hw/usb/host-libusb.c > +++ b/hw/usb/host-libusb.c [ ... ] > +static int usb_host_cpr_reclaim_interfaces(USBHostDevice *s) > +{ [ ... ] > + /* Data is sane: claim each interface on the fd and record it. */ > + for (int i =3D 0; i < conf->bNumInterfaces; i++) { > + int ifnum =3D conf->interface[i].altsetting[0].bInterfaceNumber; > + > + rc =3D libusb_claim_interface(s->dh, ifnum); > + if (rc !=3D 0) { > + usb_host_libusb_error("libusb_claim_interface", rc); > + libusb_free_config_descriptor(conf); > + return -1; > + } > + s->ifs[ifnum].claimed =3D true; > + } > + > + udev->ninterfaces =3D conf->bNumInterfaces; > + udev->configuration =3D conf->bConfigurationValue; [Severity: Low] Can this claim interfaces and set udev->configuration for a guest that never configured the device? In usb_host_open(), interfaces are not claimed, and udev->ninterfaces and udev->configuration are not set. They are only set through usb_host_set_config()->usb_host_claim_interfaces() when the guest issues SET_CONFIGURATION. usb_host_cpr_reclaim_interfaces() instead derives its work from libusb_get_active_config_descriptor(), which reflects the host kernel's active configuration. It then stores: udev->ninterfaces =3D conf->bNumInterfaces; udev->configuration =3D conf->bConfigurationValue; Nothing from the migrated state is consulted, such as the source's s->ifs[].claimed. If the guest left the device in the address state while t= he kernel's active configuration is non-zero, the target could claim interfaces the source never claimed. It could also report a non-zero configuration that the guest never selected. So the commit message statement "on the preserved FD this is a no-op at the usbfs level anyway" seems to hold only when the guest had already configured the device. I did not trace the guest-side GET_CONFIGURATION handling. Separately, if libusb_claim_interface() fails partway through the loop, for example with EBUSY, the function returns -1 after earlier interfaces have already been claimed and marked in s->ifs[ifnum].claimed: rc =3D libusb_claim_interface(s->dh, ifnum); if (rc !=3D 0) { ... return -1; } s->ifs[ifnum].claimed =3D true; There is no rollback. This seems to contradict the comment above the validation loop, "so garbage migration data can't leave it half-claimed". Would it make sense to release the earlier claims on this error path? --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/20261006-usb-= host_v3-v8-0-72ae4fb8977b@virtuozzo.com?part=3D12