From nobody Sat Feb 7 11:38:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495435198582259.744208684687; Sun, 21 May 2017 23:39:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E9297BDD0; Mon, 22 May 2017 06:39:56 +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 B702B5C6A1; Mon, 22 May 2017 06:39:56 +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 6B48C4BB7F; Mon, 22 May 2017 06:39:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4M6cnfo010424 for ; Mon, 22 May 2017 02:38:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39AC94F6AC; Mon, 22 May 2017 06:38:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 342F718EFE for ; Mon, 22 May 2017 06:38:49 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 603A8C057FA1 for ; Mon, 22 May 2017 06:38:47 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4M6SkhG094100 for ; Mon, 22 May 2017 02:38:47 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2akruwuv8e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 22 May 2017 02:38:46 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 May 2017 07:38:44 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 May 2017 07:38:41 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4M6cf7j39649524; Mon, 22 May 2017 06:38:41 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B463C5204C; Mon, 22 May 2017 06:35:51 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9D5F25203F; Mon, 22 May 2017 06:35:51 +0100 (BST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E9297BDD0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E9297BDD0 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 603A8C057FA1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=bwalk@linux.vnet.ibm.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 603A8C057FA1 From: Bjoern Walk To: libvir-list@redhat.com Date: Mon, 22 May 2017 08:38:24 +0200 In-Reply-To: <20170522063826.15949-1-bwalk@linux.vnet.ibm.com> References: <20170522063826.15949-1-bwalk@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17052206-0016-0000-0000-000004A589CC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052206-0017-0000-0000-000027C21D11 Message-Id: <20170522063826.15949-6-bwalk@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-22_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=43 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705220034 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 22 May 2017 06:38:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 22 May 2017 06:38:47 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'bwalk@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -2.7 (BAYES_50, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Bjoern Walk Subject: [libvirt] [PATCH 5/7] util: helper functions for fibre channel devices 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 22 May 2017 06:39:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We will need some convenient helper functions for managing sysfs-entries for fibre channel-backed devices. Let's implement them and make them available in the private API. Signed-off-by: Bjoern Walk Reviewed-by: John Ferlan --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/libvirt_private.syms | 5 +++ src/util/virfcp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virfcp.h | 34 +++++++++++++++++ 5 files changed, 139 insertions(+) create mode 100644 src/util/virfcp.c create mode 100644 src/util/virfcp.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 5077857b0..142b4d337 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -206,6 +206,7 @@ src/util/virdnsmasq.c src/util/virerror.c src/util/virerror.h src/util/vireventpoll.c +src/util/virfcp.c src/util/virfdstream.c src/util/virfile.c src/util/virfirewall.c diff --git a/src/Makefile.am b/src/Makefile.am index f95f30e2f..0b7cfc89a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -117,6 +117,7 @@ UTIL_SOURCES =3D \ util/virerror.c util/virerror.h \ util/virevent.c util/virevent.h \ util/vireventpoll.c util/vireventpoll.h \ + util/virfcp.c util/virfcp.h \ util/virfdstream.c util/virfdstream.h \ util/virfile.c util/virfile.h \ util/virfirewall.c util/virfirewall.h \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d361454d5..429b095bb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1586,6 +1586,11 @@ virEventPollUpdateHandle; virEventPollUpdateTimeout; =20 =20 +# util/virfcp.h +virFCIsCapableRport; +virFCReadRportValue; + + # util/virfdstream.h virFDStreamConnectUNIX; virFDStreamCreateFile; diff --git a/src/util/virfcp.c b/src/util/virfcp.c new file mode 100644 index 000000000..3c7fab917 --- /dev/null +++ b/src/util/virfcp.c @@ -0,0 +1,98 @@ +/* + * virfcp.c: Utility functions for the Fibre Channel Protocol + * + * Copyright (C) 2017 IBM Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Author: Bjoern Walk + */ + +#include + +#include "internal.h" + +#include "viralloc.h" +#include "virfile.h" +#include "virstring.h" + +#include "virfcp.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +#ifdef __linux__ + +# define SYSFS_FC_RPORT_PATH "/sys/class/fc_remote_ports" + +bool +virFCIsCapableRport(const char *rport) +{ + bool ret =3D false; + char *path =3D NULL; + + if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) + return false; + + ret =3D virFileExists(path); + VIR_FREE(path); + + return ret; +} + +int +virFCReadRportValue(const char *rport, + const char *entry, + char **result) +{ + int ret =3D -1; + char *buf =3D NULL, *p =3D NULL; + + if (virFileReadValueString(&buf, "%s/%s/%s", + SYSFS_FC_RPORT_PATH, rport, entry) < 0) { + return -1; + } + + if ((p =3D strchr(buf, '\n'))) + *p =3D '\0'; + + if (VIR_STRDUP(*result, buf) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FREE(buf); + return ret; +} + +#else + +bool +virSysfsIsCapableFCRport(const char *rport ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")= ); + return false; +} + +int +virSysfsReadFCRport(const char *rport ATTRIBUTE_UNUSED, + const char *entry ATTRIBUTE_UNUSED, + char **result ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", _("Not supported on this platform")= ); + return -1; +} + +#endif diff --git a/src/util/virfcp.h b/src/util/virfcp.h new file mode 100644 index 000000000..2bc05387a --- /dev/null +++ b/src/util/virfcp.h @@ -0,0 +1,34 @@ +/* + * virfcp.h: Utility functions for the Fibre Channel Protocol + * + * Copyright (C) 2017 IBM Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Author: Bjoern Walk + */ + +#ifndef __VIR_FCP_H__ +# define __VIR_FCP_H__ + +bool +virFCIsCapableRport(const char *rport); + +int +virFCReadRportValue(const char *rport, + const char *entry, + char **result); + +#endif --=20 2.11.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list