From nobody Thu Mar 28 17:40:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547122329592260.7216876080315; Thu, 10 Jan 2019 04:12:09 -0800 (PST) Received: from localhost ([127.0.0.1]:54626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZBs-00011m-Lh for importer@patchew.org; Thu, 10 Jan 2019 07:12:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ8n-0007Bm-Dr for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:08:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZ8m-0003Gy-El for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:08:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghZ8k-0003Fw-Ed for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:08:52 -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 mx1.redhat.com (Postfix) with ESMTPS id 6F1298666B for ; Thu, 10 Jan 2019 12:08:49 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-203.ams2.redhat.com [10.36.116.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0259010A1828; Thu, 10 Jan 2019 12:08:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EAD95A213; Thu, 10 Jan 2019 13:08:43 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 13:08:43 +0100 Message-Id: <20190110120843.3839-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 10 Jan 2019 12:08:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3] usb: assign unique serial numbers to hid devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Windows guests have trouble dealing with usb devices having identical serial numbers. So, assign unique serial numbers to usb hid devices. All other usb devices have this already. In the past the fixed serial number has been used to indicate working remote setup to linux guests. Here is a bit of history: * First there was nothing. * Then I added a rule to udev checking for serial =3D=3D 42. (this is in rhel-6). * Then systemd + udev merged. * Then I changed the rule to check for serial !=3D 1 instead, so we can use any serial but "1" which is the one the old broken devices had (this is in rhel-7). March 2014 in upstream systemd. * Then all usb power management rules where dropped from systemd (June 2015). Which I figured today (Sept 2018), after wondering that the rules are gone in fedora 28. So, three years ago the serial number check was dropped upstream, yet I hav't seen a single report about autosuspend issues (or cpu usage for usb emulation going up, which is the typical symtom). So I figured I can stop worring that changing the serial number will break things and just do it. And even if it turns out autosuspend is still an issue: I think meanwhile we can really stop worrying about guests running in old qemu versions with broken usb suspend (fixed in 0.13 !). If needed we can enable autosuspend unconditionally in guests. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-hid.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 62d18290dc..205236e9b1 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -61,10 +61,13 @@ enum { STR_PRODUCT_MOUSE, STR_PRODUCT_TABLET, STR_PRODUCT_KEYBOARD, - STR_SERIALNUMBER, + STR_SERIAL_COMPAT, STR_CONFIG_MOUSE, STR_CONFIG_TABLET, STR_CONFIG_KEYBOARD, + STR_SERIAL_MOUSE, + STR_SERIAL_TABLET, + STR_SERIAL_KEYBOARD, }; =20 static const USBDescStrings desc_strings =3D { @@ -72,10 +75,13 @@ static const USBDescStrings desc_strings =3D { [STR_PRODUCT_MOUSE] =3D "QEMU USB Mouse", [STR_PRODUCT_TABLET] =3D "QEMU USB Tablet", [STR_PRODUCT_KEYBOARD] =3D "QEMU USB Keyboard", - [STR_SERIALNUMBER] =3D "42", /* =3D=3D remote wakeup works */ + [STR_SERIAL_COMPAT] =3D "42", [STR_CONFIG_MOUSE] =3D "HID Mouse", [STR_CONFIG_TABLET] =3D "HID Tablet", [STR_CONFIG_KEYBOARD] =3D "HID Keyboard", + [STR_SERIAL_MOUSE] =3D "89126", + [STR_SERIAL_TABLET] =3D "28754", + [STR_SERIAL_KEYBOARD] =3D "68284", }; =20 static const USBDescIface desc_iface_mouse =3D { @@ -375,7 +381,7 @@ static const USBDesc desc_mouse =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_MOUSE, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_MOUSE, }, .full =3D &desc_device_mouse, .str =3D desc_strings, @@ -389,7 +395,7 @@ static const USBDesc desc_mouse2 =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_MOUSE, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_MOUSE, }, .full =3D &desc_device_mouse, .high =3D &desc_device_mouse2, @@ -404,7 +410,7 @@ static const USBDesc desc_tablet =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_TABLET, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_TABLET, }, .full =3D &desc_device_tablet, .str =3D desc_strings, @@ -418,7 +424,7 @@ static const USBDesc desc_tablet2 =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_TABLET, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_TABLET, }, .full =3D &desc_device_tablet, .high =3D &desc_device_tablet2, @@ -433,7 +439,7 @@ static const USBDesc desc_keyboard =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_KEYBOARD, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_KEYBOARD, }, .full =3D &desc_device_keyboard, .str =3D desc_strings, @@ -447,7 +453,7 @@ static const USBDesc desc_keyboard2 =3D { .bcdDevice =3D 0, .iManufacturer =3D STR_MANUFACTURER, .iProduct =3D STR_PRODUCT_KEYBOARD, - .iSerialNumber =3D STR_SERIALNUMBER, + .iSerialNumber =3D STR_SERIAL_KEYBOARD, }, .full =3D &desc_device_keyboard, .high =3D &desc_device_keyboard2, @@ -718,9 +724,7 @@ static void usb_hid_initfn(USBDevice *dev, int kind, return; } =20 - if (dev->serial) { - usb_desc_set_string(dev, STR_SERIALNUMBER, dev->serial); - } + usb_desc_create_serial(dev); usb_desc_init(dev); us->intr =3D usb_ep_get(dev, USB_TOKEN_IN, 1); hid_init(&us->hid, kind, usb_hid_changed); --=20 2.9.3