From nobody Mon Nov 25 11:35:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1605615118; cv=none; d=zohomail.com; s=zohoarc; b=ctXKM73xyw9ibYIgUszGU2qmvvE1B7/zqn7WV6bNU3g/aWyxKobpbGJQqD1H+xy3smbpo2HbEod+ggkGPYaF512T2iQoswPGfxcYFaVeAGyTS3glWJh08K0HZ8tqUqGnOm/s3WWibn0Z18IWnLeF/DhuqZEalgRDLhNndE3/9C8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605615118; h=Content-Type:Content-Transfer-Encoding:Cc: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=8B9C5MFhWHKgTs02Ok2u3OhMSKAB0DlEBzR55lqpm0Q=; b=K2nMfXGOBcZr2KKbTXIablsMwbvKtrgGGPMuj4MWzCaScVE50rRi19k3rRwfnyvtGi1dDj34/bXuq6vU1UWiVowYUjhuHYDFGoSHDtsOrgzjLA1/zgg8zH+t073phVe69Ifn3DtDrEwMKNuCDvSbBrtloj+0oAG3fLEsQ6rMprs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605615118061895.4363674182631; Tue, 17 Nov 2020 04:11:58 -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-580-8DMBERlpPDSSe4PU9ewXkg-1; Tue, 17 Nov 2020 07:11:53 -0500 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 BDFDE11CC81F; Tue, 17 Nov 2020 12:11:43 +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 950EF5C221; Tue, 17 Nov 2020 12:11:43 +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 5D24B181A07E; Tue, 17 Nov 2020 12:11:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AHCBanb032735 for ; Tue, 17 Nov 2020 07:11:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3836A9C046; Tue, 17 Nov 2020 12:11:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32462A37A3 for ; Tue, 17 Nov 2020 12:11:36 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1DE01800183 for ; Tue, 17 Nov 2020 12:11:36 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-nFhx953_PYqIzzvfr3UTYA-1; Tue, 17 Nov 2020 07:11:33 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AHC1QFR111510 for ; Tue, 17 Nov 2020 07:11:33 -0500 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com with ESMTP id 34vbepwn6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Nov 2020 07:11:33 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AHC8lnv018426 for ; Tue, 17 Nov 2020 12:11:31 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 34t6v89ju7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Nov 2020 12:11:31 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AHCBStg57147662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Nov 2020 12:11:28 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B87BAE055; Tue, 17 Nov 2020 12:11:28 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C94CAE045; Tue, 17 Nov 2020 12:11:28 +0000 (GMT) Received: from m46lp68.lnxne.boe (unknown [9.152.108.100]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Nov 2020 12:11:28 +0000 (GMT) X-MC-Unique: 8DMBERlpPDSSe4PU9ewXkg-1 X-MC-Unique: nFhx953_PYqIzzvfr3UTYA-1 From: Shalini Chellathurai Saroja To: Libvirt Mailing List Subject: [PATCH libvirt v3 09/11] node_device: refactor address retrieval of node device Date: Tue, 17 Nov 2020 13:11:03 +0100 Message-Id: <20201117121105.2854458-10-shalini@linux.ibm.com> In-Reply-To: <20201117121105.2854458-1-shalini@linux.ibm.com> References: <20201117121105.2854458-1-shalini@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-17_03:2020-11-17, 2020-11-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011170085 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Shalini Chellathurai Saroja 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 Content-Type: text/plain; charset="utf-8" Use switch statements instead of if-else condition in the method nodeDeviceFindAddressByName to retrieve address of a node device. Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski --- src/node_device/node_device_driver.c | 30 ++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index f5ea973c..65c647f5 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -638,7 +638,8 @@ nodeDeviceFindAddressByName(const char *name) =20 def =3D virNodeDeviceObjGetDef(dev); for (caps =3D def->caps; caps !=3D NULL; caps =3D caps->next) { - if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_PCI_DEV) { + switch (caps->data.type) { + case VIR_NODE_DEV_CAP_PCI_DEV: { virPCIDeviceAddress pci_addr =3D { .domain =3D caps->data.pci_dev.domain, .bus =3D caps->data.pci_dev.bus, @@ -648,7 +649,9 @@ nodeDeviceFindAddressByName(const char *name) =20 addr =3D virPCIDeviceAddressAsString(&pci_addr); break; - } else if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_CSS_DEV) { + } + + case VIR_NODE_DEV_CAP_CSS_DEV: { virDomainDeviceCCWAddress ccw_addr =3D { .cssid =3D caps->data.ccw_dev.cssid, .ssid =3D caps->data.ccw_dev.ssid, @@ -657,6 +660,29 @@ nodeDeviceFindAddressByName(const char *name) =20 addr =3D virDomainCCWAddressAsString(&ccw_addr); break; + } + + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_USB_DEV: + case VIR_NODE_DEV_CAP_USB_INTERFACE: + case VIR_NODE_DEV_CAP_NET: + case VIR_NODE_DEV_CAP_SCSI_HOST: + case VIR_NODE_DEV_CAP_SCSI_TARGET: + case VIR_NODE_DEV_CAP_SCSI: + case VIR_NODE_DEV_CAP_STORAGE: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_SCSI_GENERIC: + case VIR_NODE_DEV_CAP_DRM: + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_CCW_DEV: + case VIR_NODE_DEV_CAP_VDPA: + case VIR_NODE_DEV_CAP_AP_CARD: + case VIR_NODE_DEV_CAP_AP_QUEUE: + case VIR_NODE_DEV_CAP_AP_MATRIX: + case VIR_NODE_DEV_CAP_LAST: + break; } } =20 --=20 2.26.2