From nobody Mon Feb 9 01:36:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657631776; cv=none; d=zohomail.com; s=zohoarc; b=HhfgVd30LJ07SqAHI8HVb0uRWblKmB7fq11+bJpzeBY/SDq9rwzhRDbk94wnhxX105hnW6VqOmVN5bF87SXuFver1jaz50GcBaIHy0wzZgRbtjuKJN6uvRcOYpLdXwaPlhcHesL7tIo4RdSjZKl8v+8Xz+SCO3tIBCEfXg6gF2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657631776; h=Content-Type:Content-Transfer-Encoding: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=GFXxJfqUx+dxjEF4XxtKNWsbpSmXmMQwVqcVWyCrXGc=; b=SelPKnjs428Z7Q9VAc6xnZXXlyJu3spPO5AHSutddBo/l4UyjcTscIRz+SALHf619MuBUARhDIjdWH8bVX+a2hK2lRdunu6rsuq0eLA5s/BIMj3RqDLsUAhR22sAXEB5l1I6ROcWTalNKpsRDqAKKGmP/AJb70ztuyqNNCgaI7k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1657631776357198.06649701795516; Tue, 12 Jul 2022 06:16:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-JXTeIF0zO06MiMTuHFZQuQ-1; Tue, 12 Jul 2022 09:13:43 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EDEBB85A58B; Tue, 12 Jul 2022 13:13:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7C19492C3B; Tue, 12 Jul 2022 13:13:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8FFAA1947060; Tue, 12 Jul 2022 13:13:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 394991947058 for ; Tue, 12 Jul 2022 13:13:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2448E2026D64; Tue, 12 Jul 2022 13:13:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3C6A2026D07 for ; Tue, 12 Jul 2022 13:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657631775; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GFXxJfqUx+dxjEF4XxtKNWsbpSmXmMQwVqcVWyCrXGc=; b=DEMlYGzexKpbTELbeMS0IyA1YTXuC1Lze8Lc+Lj1bjt9BmHxd/ebRq2VyKDbcyr1BPCm/h qmScymsuDHTNTNm7Pr7efT4+fqIWhUeoNSYZfSscByfEu2W/KFiKpdacUX2Nd/2PJ+aBDZ BnGAErENOt15I+gTtVJWyRROSxvtXVE= X-MC-Unique: JXTeIF0zO06MiMTuHFZQuQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] conf: Introduce @guestReset to hostdev's Date: Tue, 12 Jul 2022 15:13:31 +0200 Message-Id: <32dfa9ec0598eb84267672a34442b1592524baa6.1657631390.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657631777060100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Some USB devices have a buggy firmware that either crashes on device reset, or make the device unusable in some other way. Fortunately, QEMU offers a way to skip device reset either completely, or if device is not initialized yet. Expose this ability to users under: Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 15 ++++++++++++++- src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 13 +++++++++++++ src/conf/schemas/domaincommon.rng | 9 +++++++++ tests/qemuxml2argvdata/hostdev-usb-address.xml | 2 +- .../hostdev-usb-address.x86_64-latest.xml | 2 +- 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 89b627f4bd..3ea094e64c 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4051,7 +4051,7 @@ for PCI (KVM only) and 1.0.6 for SCSI (KVM only)` : ... - + @@ -4231,6 +4231,19 @@ or: optional drop if missing at any start attempt =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 + :since:`Since 8.6.0`, the ``source`` element can contain ``guestRese= t`` + attribute with the following value: + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + off all guest initiated device reset requests are ignored + uninitialized device request is ignored if device is initialized, + otherwise reset is performed + on device is reset on every guest initiated request + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + This attribute can be helpful when assigning an USB device with a + firmware that crashes on reset. + ``pci`` PCI devices can only be described by their ``address``. :since:`Since 6.8.0 (Xen only)` , the ``source`` element of a PCI de= vice diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b639022396..ced25286bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1042,6 +1042,14 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, "iscsi", ); =20 +VIR_ENUM_IMPL(virDomainHostdevSubsysUSBGuestReset, + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST, + "default", + "off", + "uninitialized", + "on", +); + VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIHostProtocol, VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST, "none", @@ -5489,6 +5497,11 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, return -1; virTristateBoolToBool(autoAddress, &usbsrc->autoAddress); =20 + if (virXMLPropEnum(node, "guestReset", + virDomainHostdevSubsysUSBGuestResetTypeFromString, + VIR_XML_PROP_NONZERO, &usbsrc->guestReset) < 0) + return -1; + /* Product can validly be 0, so we need some extra help to determine * if it is uninitialized */ vendorNode =3D virXPathNode("./vendor", ctxt); @@ -22989,6 +23002,11 @@ virDomainHostdevDefFormatSubsysUSB(virBuffer *buf, if (def->missing && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) virBufferAddLit(&sourceAttrBuf, " missing=3D'yes'"); =20 + if (usbsrc->guestReset) { + virBufferAsprintf(&sourceAttrBuf, " guestReset=3D'%s'", + virDomainHostdevSubsysUSBGuestResetTypeToString(= usbsrc->guestReset)); + } + if (usbsrc->vendor) { virBufferAsprintf(&sourceChildBuf, "\n", us= bsrc->vendor); virBufferAsprintf(&sourceChildBuf, "\n", u= sbsrc->product); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c56b84683c..90de50c12f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -233,6 +233,17 @@ typedef enum { =20 VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol); =20 +typedef enum { + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_DEFAULT =3D 0, + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_OFF, /* reset forbidden */ + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_UNINITIALIZED, /* reset iff uniniti= alized */ + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_ON, /* reset allowed */ + + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST +} virDomainHostdevSubsysUSBGuestReset; + +VIR_ENUM_DECL(virDomainHostdevSubsysUSBGuestReset); + struct _virDomainHostdevSubsysUSB { bool autoAddress; /* bus/device were filled automatically based on vendor/product */ @@ -241,6 +252,8 @@ struct _virDomainHostdevSubsysUSB { =20 unsigned vendor; unsigned product; + + virDomainHostdevSubsysUSBGuestReset guestReset; }; =20 struct _virDomainHostdevSubsysPCI { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index da2fb0d5cb..faa2561665 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5936,6 +5936,15 @@ + + + + off + uninitialized + on + + + diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.xml b/tests/qemuxml= 2argvdata/hostdev-usb-address.xml index 03c802a532..50c02f9b0e 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address.xml +++ b/tests/qemuxml2argvdata/hostdev-usb-address.xml @@ -26,7 +26,7 @@ - +
diff --git a/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml= b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml index e5e3620971..2e927252a8 100644 --- a/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml @@ -34,7 +34,7 @@