From nobody Tue Feb 10 01:59:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605617833; cv=none; d=zohomail.com; s=zohoarc; b=JJ8ChkYpUlBW7ctQETepT1XEo04i1/xOyrG1I+fCFX08CmadPTdVO5I483HJ3jVeZKa8YERP8JCetrIwVP4iLc9TKnjX06AjePpX1xUAu5pw68PQUn962I87vs5d3J2VOnM3bxNQnt5LJz+O0q5pvpayaVeI2MZQChcrPhk+pMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605617833; 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=B9EZJWpUu7RtahNzWaYLThF0zbKwGkhPhyZhLifxW4k=; b=YeNQZ0W0YIdAx51bcChTDADk5cl6bKGot5Zc9eyb9m7xACoOvVbn8/YuspwJ/sCX6rPKBEMNiiDgm6IjlnIPNCgoJlEnCHtx3+No0F5+dqOxXmfFsxULTVeMjfNFkgCeVLQF76euhPXDQ0JH0JFVOUkg5iiBqNEtpUrvsUPdWSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605617833186625.0735223130696; Tue, 17 Nov 2020 04:57:13 -0800 (PST) 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-45-6yeIdbUhPm-wEVaAWQyhbg-1; Tue, 17 Nov 2020 07:57:09 -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 74CA3879520; Tue, 17 Nov 2020 12:57:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 513C95B4B6; Tue, 17 Nov 2020 12:57:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1FADD180B657; Tue, 17 Nov 2020 12:57:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AHCuTBo004721 for ; Tue, 17 Nov 2020 07:56:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 42E4F5C1D7; Tue, 17 Nov 2020 12:56:29 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-10.ams2.redhat.com [10.36.115.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E7E05C1D0; Tue, 17 Nov 2020 12:56:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605617832; 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=B9EZJWpUu7RtahNzWaYLThF0zbKwGkhPhyZhLifxW4k=; b=Vz+WrIs4RxNaX9y+/hboDiFFrOA5j434D2+e9yJLYvhcL/D4CFatt+zHpsznSrKus+ofhM LIQxNnbFGDTdpQzkVzV1Ve4kbzv3g9eKSh/0zxTsnB3RHKMGubipomKRo4PfnpBsRWik4s 7AKehjHAOLVUWZQtOlG1JOpvHnS1CC4= X-MC-Unique: 6yeIdbUhPm-wEVaAWQyhbg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] nodedev: report errors about missing integer properties Date: Tue, 17 Nov 2020 12:56:08 +0000 Message-Id: <20201117125608.177278-5-berrange@redhat.com> In-Reply-To: <20201117125608.177278-1-berrange@redhat.com> References: <20201117125608.177278-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The helper methods for getting integer properties ignore a missing property setting its value to zero. This lack of error reporting resulted in missing the regression handling hotplug of USB devices with the vendor and model IDs getting set to zero silently. The few callers which relied on this silent defaulting have been fixed, so now we can report fatal errors immediately. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/node_device/node_device_udev.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index a25babcf0d..86b0ece5c0 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -169,10 +169,17 @@ udevGetIntProperty(struct udev_device *udev_device, const char *str =3D NULL; =20 str =3D udevGetDeviceProperty(udev_device, property_key); + if (!str) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing udev property '%s' on '%s'"), + property_key, udev_device_get_sysname(udev_device)); + return -1; + } =20 - if (str && virStrToLong_i(str, NULL, base, value) < 0) { + if (virStrToLong_i(str, NULL, base, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to convert '%s' to int"), str); + _("Failed to parse int '%s' from udev property '%s'= on '%s'"), + str, property_key, udev_device_get_sysname(udev_dev= ice)); return -1; } return 0; @@ -188,10 +195,17 @@ udevGetUintProperty(struct udev_device *udev_device, const char *str =3D NULL; =20 str =3D udevGetDeviceProperty(udev_device, property_key); + if (!str) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing udev property '%s' on '%s'"), + property_key, udev_device_get_sysname(udev_device)); + return -1; + } =20 - if (str && virStrToLong_ui(str, NULL, base, value) < 0) { + if (virStrToLong_ui(str, NULL, base, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to convert '%s' to int"), str); + _("Failed to parse uint '%s' from udev property '%s= ' on '%s'"), + str, property_key, udev_device_get_sysname(udev_dev= ice)); return -1; } return 0; --=20 2.28.0