From nobody Thu May 2 23:38:21 2024 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=1622619489; cv=none; d=zohomail.com; s=zohoarc; b=mVs+kJSfWWVaLgOzeHWyEYY87mIj1BkjeB/J8L1LOHe3/PvFkYrcwSCEBEom5xF2EzyQdDtIHJX0d53ToHsrOx5OyRiQS0fp9CgquONfPoR1bq+Mk2pqKW/kitLfJM0Avb7CHbimnIENOFAKmNtQVCaFuB2fMfYjSVsevQVokOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622619489; 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=ALYqXgDPrH3LaZE3Bgou40UzriznJ6BUZCELgv0A5ps=; b=UxtR+o84wRuaiZfJG4HPkQrPrVQbfwMzvR3ZPBgWxoYJfU0pYow1MSXb8znxNLnoUN3FnOFxGh3YNdzbFYaS7gbrTL9Uj2EIqDzQeVOt13erORvroiLaN4BYVMsSrupP5opDbFLnZjJ91kIs9Ma/nZluBkucVRCBEPsarN0QkCk= 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 1622619489652509.3221736002521; Wed, 2 Jun 2021 00:38:09 -0700 (PDT) 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-217-jODGCMiONx--uM97IaTBow-1; Wed, 02 Jun 2021 03:38:05 -0400 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 2DCD9106BB2A; Wed, 2 Jun 2021 07:37:59 +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 D7CFB6A03D; Wed, 2 Jun 2021 07:37:58 +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 0B92E1801264; Wed, 2 Jun 2021 07:37:52 +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 1527boDb021064 for ; Wed, 2 Jun 2021 03:37:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id EBFF75C230; Wed, 2 Jun 2021 07:37:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 707CD5C67A for ; Wed, 2 Jun 2021 07:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622619488; 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=ALYqXgDPrH3LaZE3Bgou40UzriznJ6BUZCELgv0A5ps=; b=Gxt1dD16vIg7X2hZIg5PQ6b+qBZAyND3LBzWVXvrysC88FoyCFWhPQf64uiHWXcNG1ZpsK n1zc0p1uRBgXnJBkn/ZNUreK2Q7FLX8nTsg0VU8/uto+Hv5ac1pEve8fN0pOgBteb3zOOx b/0CJsKVmfJyEypHapk5YB3FMLlBHKk= X-MC-Unique: jODGCMiONx--uM97IaTBow-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] node_device_udev: Make udevGenerateDeviceName() return void Date: Wed, 2 Jun 2021 09:37:40 +0200 Message-Id: <408e1e220caea67a3047ca64da4c45ec33b93835.1622619418.git.mprivozn@redhat.com> In-Reply-To: References: 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.13 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) Content-Type: text/plain; charset="utf-8" This function can't fail really as it's returning 0 no matter what. This is probably a residue from old days when we cared about propagating OOM errors. Now we just abort. Make its return type void then. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 52 ++++++++++-------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 658170a767..d5f3beb389 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -319,7 +319,7 @@ udevGetUint64SysfsAttr(struct udev_device *udev_device, } =20 =20 -static int +static void udevGenerateDeviceName(struct udev_device *device, virNodeDeviceDef *def, const char *s) @@ -327,8 +327,6 @@ udevGenerateDeviceName(struct udev_device *device, nodeDeviceGenerateName(def, udev_device_get_subsystem(device), udev_device_get_sysname(device), s); - - return 0; } =20 static virMutex pciaccessMutex =3D VIR_MUTEX_INITIALIZER; @@ -410,8 +408,7 @@ udevProcessPCI(struct udev_device *device, goto cleanup; } =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - goto cleanup; + udevGenerateDeviceName(device, def, NULL); =20 /* The default value is -1, because it can't be 0 * as zero is valid node number. */ @@ -493,8 +490,7 @@ udevProcessDRMDevice(struct udev_device *device, virNodeDevCapDRM *drm =3D &def->caps->data.drm; int minor; =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 if (udevGetIntProperty(device, "MINOR", &minor, 10) < 0) return -1; @@ -544,8 +540,7 @@ udevProcessUSBDevice(struct udev_device *device, &usb_dev->product_name) < 0) return -1; =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -573,8 +568,7 @@ udevProcessUSBInterface(struct udev_device *device, &usb_if->protocol, 16) < 0) return -1; =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -605,8 +599,7 @@ udevProcessNetworkInterface(struct udev_device *device, if (udevGetUintSysfsAttr(device, "addr_len", &net->address_len, 0) < 0) return -1; =20 - if (udevGenerateDeviceName(device, def, net->address) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, net->address); =20 if (virNetDevGetLinkInfo(net->ifname, &net->lnk) < 0) return -1; @@ -638,8 +631,7 @@ udevProcessSCSIHost(struct udev_device *device G_GNUC_U= NUSED, =20 virNodeDeviceGetSCSIHostCaps(&def->caps->data.scsi_host); =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -658,8 +650,7 @@ udevProcessSCSITarget(struct udev_device *device, =20 virNodeDeviceGetSCSITargetCaps(def->sysfs_path, &def->caps->data.scsi_= target); =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -755,8 +746,7 @@ udevProcessSCSIDevice(struct udev_device *device G_GNUC= _UNUSED, goto cleanup; } =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - goto cleanup; + udevGenerateDeviceName(device, def, NULL); =20 ret =3D 0; =20 @@ -1008,8 +998,7 @@ udevProcessStorage(struct udev_device *device, goto cleanup; } =20 - if (udevGenerateDeviceName(device, def, storage->serial) !=3D 0) - goto cleanup; + udevGenerateDeviceName(device, def, storage->serial); =20 cleanup: VIR_DEBUG("Storage ret=3D%d", ret); @@ -1025,8 +1014,7 @@ udevProcessSCSIGeneric(struct udev_device *dev, !def->caps->data.sg.path) return -1; =20 - if (udevGenerateDeviceName(dev, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(dev, def, NULL); =20 return 0; } @@ -1068,8 +1056,7 @@ udevProcessMediatedDevice(struct udev_device *dev, if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0) goto cleanup; =20 - if (udevGenerateDeviceName(dev, def, NULL) !=3D 0) - goto cleanup; + udevGenerateDeviceName(dev, def, NULL); =20 data->iommuGroupNumber =3D iommugrp; =20 @@ -1114,8 +1101,7 @@ udevProcessCCW(struct udev_device *device, if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) return -1; =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -1134,8 +1120,7 @@ udevProcessCSS(struct udev_device *device, if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) return -1; =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 if (virNodeDeviceGetCSSDynamicCaps(def->sysfs_path, &def->caps->data.c= cw_dev) < 0) return -1; @@ -1181,8 +1166,7 @@ static int udevProcessVDPA(struct udev_device *device, virNodeDeviceDef *def) { - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 if (udevGetVDPACharDev(def->sysfs_path, &def->caps->data) < 0) return -1; @@ -1209,8 +1193,7 @@ udevProcessAPCard(struct udev_device *device, return -1; } =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } @@ -1235,8 +1218,7 @@ udevProcessAPQueue(struct udev_device *device, return -1; } =20 - if (udevGenerateDeviceName(device, def, NULL) !=3D 0) - return -1; + udevGenerateDeviceName(device, def, NULL); =20 return 0; } --=20 2.31.1 From nobody Thu May 2 23:38:21 2024 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=1622619489; cv=none; d=zohomail.com; s=zohoarc; b=YrNpV8HRzAcrqfSyjB1eQ0ekVDIZ5P38ma6iy0ijra4gp8yRxs0QzT+9MliV0/SMldBQOzcBocsSoBy7p3TaJjJw5iST5RK6hfrJgbyoE0N500xS4r5yVVVDg/kQ/HDg7mleTEWUUVRSu3o/55Bn9/PHdVKxT36s1rnZvyJJNyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622619489; 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=mo42AvGYRWRW4WjMMWsbT3/8YnEvssnuNor9EHUVb2g=; b=iZeIzmj+UZ+tAU1gDPOvmJygpT8CDn32CIKVDbNZ3VXxiSZQfoB41TeKFMUTTl32s/CgWQg64aJiu5Aru0ICt8KICNpxsaEOgRF9y/OdB5KcWtd3FGX+mnzQz0x+mA8mRQZw46qjapci2Oq3yfWS8zL7yaS0aLFGlV1DCiRmkYo= 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 162261948954578.47993832426982; Wed, 2 Jun 2021 00:38:09 -0700 (PDT) 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-119-L_vsGskcPS6GcbWwKnimxA-1; Wed, 02 Jun 2021 03:38:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E7C5107ACC7; Wed, 2 Jun 2021 07:37:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F6255D6CF; Wed, 2 Jun 2021 07:37:58 +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 C08EC44A59; Wed, 2 Jun 2021 07:37:53 +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 1527bpt1021080 for ; Wed, 2 Jun 2021 03:37:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id C44792CFB1; Wed, 2 Jun 2021 07:37:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4831E5C230 for ; Wed, 2 Jun 2021 07:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622619488; 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=mo42AvGYRWRW4WjMMWsbT3/8YnEvssnuNor9EHUVb2g=; b=ckUmZppWm6Bw9QCfqoQGWcq+krp9N7lWT1UmIxgUHlIe6l3ggvinzR3RblvEKvQ9BjPYRO ripUru2tbvSLPozHELc1tRH5a/Mngt6nAXz62K48KJXdVA72dmkLY2sCh6XpHgPftMLK+y sUBONT/hwRFfv7VZmbmoO5geOFYWvys= X-MC-Unique: L_vsGskcPS6GcbWwKnimxA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] node_device_udev: Make udevGetStringProperty() return void Date: Wed, 2 Jun 2021 09:37:41 +0200 Message-Id: <3c6b518fd46d478bd14ae71e813fe4235ec4fb57.1622619418.git.mprivozn@redhat.com> In-Reply-To: References: 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.15 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) Content-Type: text/plain; charset="utf-8" This function can't fail really as it's returning 0 no matter what. This is probably a residue from old days when we cared about propagating OOM errors. Now we just abort. Make its return type void then. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 46 ++++++++++-------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index d5f3beb389..f48789d98f 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -165,14 +165,12 @@ udevGetDeviceProperty(struct udev_device *udev_device, } =20 =20 -static int +static void udevGetStringProperty(struct udev_device *udev_device, const char *property_key, char **value) { *value =3D g_strdup(udevGetDeviceProperty(udev_device, property_key)); - - return 0; } =20 =20 @@ -517,10 +515,9 @@ udevProcessUSBDevice(struct udev_device *device, if (udevGetUintProperty(device, "ID_VENDOR_ID", &usb_dev->vendor, 16) = < 0) return -1; =20 - if (udevGetStringProperty(device, - "ID_VENDOR_FROM_DATABASE", - &usb_dev->vendor_name) < 0) - return -1; + udevGetStringProperty(device, + "ID_VENDOR_FROM_DATABASE", + &usb_dev->vendor_name); =20 if (!usb_dev->vendor_name && udevGetStringSysfsAttr(device, "manufacturer", @@ -530,10 +527,9 @@ udevProcessUSBDevice(struct udev_device *device, if (udevGetUintProperty(device, "ID_MODEL_ID", &usb_dev->product, 16) = < 0) return -1; =20 - if (udevGetStringProperty(device, - "ID_MODEL_FROM_DATABASE", - &usb_dev->product_name) < 0) - return -1; + udevGetStringProperty(device, + "ID_MODEL_FROM_DATABASE", + &usb_dev->product_name); =20 if (!usb_dev->product_name && udevGetStringSysfsAttr(device, "product", @@ -587,10 +583,7 @@ udevProcessNetworkInterface(struct udev_device *device, net->subtype =3D VIR_NODE_DEV_CAP_NET_80203; } =20 - if (udevGetStringProperty(device, - "INTERFACE", - &net->ifname) < 0) - return -1; + udevGetStringProperty(device, "INTERFACE", &net->ifname); =20 if (udevGetStringSysfsAttr(device, "address", &net->address) < 0) @@ -798,9 +791,7 @@ udevProcessRemoveableMedia(struct udev_device *device, def->caps->data.storage.flags |=3D VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; =20 - if (udevGetStringProperty(device, "ID_FS_LABEL", - &storage->media_label) < 0) - return -1; + udevGetStringProperty(device, "ID_FS_LABEL", &storage->media_label); =20 if (udevGetUint64SysfsAttr(device, "size", &storage->num_blocks) < 0) @@ -946,10 +937,8 @@ udevProcessStorage(struct udev_device *device, =20 storage->block =3D g_strdup(devnode); =20 - if (udevGetStringProperty(device, "ID_BUS", &storage->bus) < 0) - goto cleanup; - if (udevGetStringProperty(device, "ID_SERIAL", &storage->serial) < 0) - goto cleanup; + udevGetStringProperty(device, "ID_BUS", &storage->bus); + udevGetStringProperty(device, "ID_SERIAL", &storage->serial); =20 if (udevGetStringSysfsAttr(device, "device/vendor", &storage->vendor) = < 0) goto cleanup; @@ -965,8 +954,7 @@ udevProcessStorage(struct udev_device *device, * expected, so I don't see a problem with not having a property * for it. */ =20 - if (udevGetStringProperty(device, "ID_TYPE", &storage->drive_type) < 0) - goto cleanup; + udevGetStringProperty(device, "ID_TYPE", &storage->drive_type); =20 if (!storage->drive_type || STREQ(def->caps->data.storage.drive_type, "generic")) { @@ -1010,9 +998,7 @@ static int udevProcessSCSIGeneric(struct udev_device *dev, virNodeDeviceDef *def) { - if (udevGetStringProperty(dev, "DEVNAME", &def->caps->data.sg.path) < = 0 || - !def->caps->data.sg.path) - return -1; + udevGetStringProperty(dev, "DEVNAME", &def->caps->data.sg.path); =20 udevGenerateDeviceName(dev, def, NULL); =20 @@ -1317,8 +1303,7 @@ udevGetDeviceType(struct udev_device *device, =20 /* The following devices do not set the DEVTYPE property, therefore * we need to rely on the SUBSYSTEM property */ - if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) < 0) - return -1; + udevGetStringProperty(device, "SUBSYSTEM", &subsystem); =20 if (STREQ_NULLABLE(subsystem, "scsi_generic")) *type =3D VIR_NODE_DEV_CAP_SCSI_GENERIC; @@ -1499,8 +1484,7 @@ udevAddOneDevice(struct udev_device *device) =20 def->sysfs_path =3D g_strdup(udev_device_get_syspath(device)); =20 - if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0) - goto cleanup; + udevGetStringProperty(device, "DRIVER", &def->driver); =20 def->caps =3D g_new0(virNodeDevCapsDef, 1); =20 --=20 2.31.1 From nobody Thu May 2 23:38:21 2024 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=1622619544; cv=none; d=zohomail.com; s=zohoarc; b=hTluctw9/qrCt222pPIK67GTHEL+3JBKNHKlZgB3k8x9QMao/fUX7C3pMaKW9Q+7DoAm+Ry0X87h+xHlnG5ma8NQtxiKaJ0jUi2MXaqVq4MlZj0+0DuY8JnWFKYPn8ORf5lgI8yLLDxsRDuxPhgc3xRyMPI/zMz494+YK4yckWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622619544; 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=zwavbmWV2CdWHw4EU/lib5bIJAUFLLq+EeQd03SUtmE=; b=OQwlUlLg6LXpogjVNIMTTTm2K2/doAhOC6NaMzppjPZgO1m6ywfsyAFiVXzI+qL3VOR+wd12PVSq9phCLXKkqejqjemtD4OewKwJ/xYgLPInPxZ9+XGzrDnzH9kjD1vj/gQv1H85IQB7Ie9942KzwG4/GZYVnOghYPTT3jNh5r4= 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) header.from= 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 1622619544894824.7744813211024; Wed, 2 Jun 2021 00:39:04 -0700 (PDT) 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-515--2d-5knhOKC7fDPLTW9laQ-1; Wed, 02 Jun 2021 03:38:19 -0400 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 D40511854E25; Wed, 2 Jun 2021 07:38:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4F9B10023B0; Wed, 2 Jun 2021 07:38:13 +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 670A144A61; Wed, 2 Jun 2021 07:38:13 +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 1527bqI6021092 for ; Wed, 2 Jun 2021 03:37:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C9405C230; Wed, 2 Jun 2021 07:37:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 204E75C648 for ; Wed, 2 Jun 2021 07:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622619543; 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=zwavbmWV2CdWHw4EU/lib5bIJAUFLLq+EeQd03SUtmE=; b=AzttJoplqsMhwxy5HPddgT32JMN//CiRwDHFXLpE7MQQfdcXfY1ep0SRqz+Hw86aSSkVis WSPJAORovmYBPtpGUgcdummj8SW+RjqGPnmLIlfh6f6ksZZPEFTEGkrveQfI2BAF5pvPvp 6umlUsFRafUro4BFRBuO01LKvyYUvLc= X-MC-Unique: -2d-5knhOKC7fDPLTW9laQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] node_device_udev: Don't overwrite @ret in udevProcessStorage() Date: Wed, 2 Jun 2021 09:37:42 +0200 Message-Id: <580ee2994c523c9cec4f95ba77e94bfcd1c95cea.1622619418.git.mprivozn@redhat.com> In-Reply-To: References: 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.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" Let's use a different variable for storing retvals of helper functions. This way the usual function pattern can be restored. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index f48789d98f..3c31e6cde4 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -927,6 +927,7 @@ udevProcessStorage(struct udev_device *device, { virNodeDevCapStorage *storage =3D &def->caps->data.storage; int ret =3D -1; + int rv; const char* devnode; =20 devnode =3D udev_device_get_devnode(device); @@ -971,22 +972,26 @@ udevProcessStorage(struct udev_device *device, } =20 if (STREQ(def->caps->data.storage.drive_type, "cd")) { - ret =3D udevProcessCDROM(device, def); + rv =3D udevProcessCDROM(device, def); } else if (STREQ(def->caps->data.storage.drive_type, "disk")) { - ret =3D udevProcessDisk(device, def); + rv =3D udevProcessDisk(device, def); } else if (STREQ(def->caps->data.storage.drive_type, "floppy")) { - ret =3D udevProcessFloppy(device, def); + rv =3D udevProcessFloppy(device, def); } else if (STREQ(def->caps->data.storage.drive_type, "sd")) { - ret =3D udevProcessSD(device, def); + rv =3D udevProcessSD(device, def); } else if (STREQ(def->caps->data.storage.drive_type, "dasd")) { - ret =3D udevProcessDASD(device, def); + rv =3D udevProcessDASD(device, def); } else { VIR_DEBUG("Unsupported storage type '%s'", def->caps->data.storage.drive_type); goto cleanup; } =20 + if (rv < 0) + goto cleanup; + udevGenerateDeviceName(device, def, storage->serial); + ret =3D 0; =20 cleanup: VIR_DEBUG("Storage ret=3D%d", ret); --=20 2.31.1 From nobody Thu May 2 23:38:21 2024 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=1622619502; cv=none; d=zohomail.com; s=zohoarc; b=WLV5WHJBYJJimkq3uiyXrJ1c/RmgXsxfKhb2iZVsq9V3wsmby5alR1obO4UHoGT/T5MW7gzLH/FXe+ea1NSyTgxQij7Gu7d7n3iNczxujP/B3k0OIrNR1Kwd6G7kYJuHaqCGeVWVEfIfZt9IMMJxWxaTqbzVoCB5RgsFwA2q6Yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622619502; 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=9qz07JOU3qxIWItVYOED97bn1PSmkoUGgCAg1XFWS+w=; b=JSSTppJ4wOQJM5cWtiIkCjV/aP2Hwng/2rMPxlFdOyStFh71uNxN0gaANZ6o98FtsMgorYcK2jTgywY6afPgmtnwuCBeeoaKH6bzejc1oYw1Dn7p0b869LrjdGuS2KxTY5e/pea9EA/eS5TJoPI6wyNC7MEqzxhRH5W3UwQpKJk= 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 1622619502165704.7342482080057; Wed, 2 Jun 2021 00:38:22 -0700 (PDT) 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-515-QURXcCsoOmu-FvEOth1dpw-1; Wed, 02 Jun 2021 03:38:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6FC51854E24; Wed, 2 Jun 2021 07:38:13 +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 81B945C6B8; Wed, 2 Jun 2021 07:38:13 +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 34B7E180B7B6; Wed, 2 Jun 2021 07:38:13 +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 1527brDf021106 for ; Wed, 2 Jun 2021 03:37:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73F452CFB1; Wed, 2 Jun 2021 07:37:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECA705C230 for ; Wed, 2 Jun 2021 07:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622619501; 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=9qz07JOU3qxIWItVYOED97bn1PSmkoUGgCAg1XFWS+w=; b=g7DJSASqlD7BDCsKMpmvNukzFJOBZ9ACrlaxoxcnUKNWqKDFbQQKJ6yBZC+9E8aTe/Xf7h 0Y/W2PUjpREFi2c5SF4vUa07crBL87V5TsiWtdFQXBFnt+IjQ1iqXC22lYyf8tnnz/HIrv ZZLQLjb07kqAHVVJgZYXRabBxSLZU9s= X-MC-Unique: QURXcCsoOmu-FvEOth1dpw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] node_device_udev: Also process ID_TYPE=cd/dvd in udevProcessStorage() Date: Wed, 2 Jun 2021 09:37:43 +0200 Message-Id: In-Reply-To: References: 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.16 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) Content-Type: text/plain; charset="utf-8" When processing node devices, the udevProcessStorage() will be called if the device is some form of storage. In here, ID_TYPE attribute is queried and depending on its value one of more specialized helper functions is called. For instance, for ID_TYPE=3D=3D"cd" the udevProcessCDROM() is called, for ID_TYPE=3D=3D"disk" the udevProcessDisk() is called, and so on. But there's a problem with ID_TYPE and its values. Coming from udev, we are not guaranteed that ID_TYPE will contain "cd" for CDROM devices. In fact, there's a rule installed by sg3_utils that will overwrite ID_TYPE to "cd/dvd" leaving us with an unhandled type. Fortunately, this was fixed in their upstream, but there are still versions out there, on OS platforms that we aim to support that contain the problematic rule. Therefore, we should accept both strings. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1848875 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/node_device/node_device_udev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 3c31e6cde4..b1c97d30b1 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -971,7 +971,8 @@ udevProcessStorage(struct udev_device *device, goto cleanup; } =20 - if (STREQ(def->caps->data.storage.drive_type, "cd")) { + if (STREQ(def->caps->data.storage.drive_type, "cd") || + STREQ(def->caps->data.storage.drive_type, "cd/dvd")) { rv =3D udevProcessCDROM(device, def); } else if (STREQ(def->caps->data.storage.drive_type, "disk")) { rv =3D udevProcessDisk(device, def); --=20 2.31.1