[libvirt] [PATCH 10/11] util: Introduce virGetFCHostNameByFabricWWN
Ján Tomko
jtomko at redhat.com
Mon Jan 2 14:51:08 UTC 2017
On Fri, Nov 18, 2016 at 09:26:36AM -0500, John Ferlan wrote:
>Create a utility routine in order to read the scsi_host fabric_name files
>looking for a match to a passed fabric_name
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/libvirt_private.syms | 1 +
> src/util/virutil.c | 86 ++++++++++++++++++++++++++++++++++++++++--------
> src/util/virutil.h | 4 +++
> 3 files changed, 78 insertions(+), 13 deletions(-)
>
>diff --git a/src/util/virutil.c b/src/util/virutil.c
>index a135819..fb72f2d 100644
>--- a/src/util/virutil.c
>+++ b/src/util/virutil.c
>@@ -2166,6 +2166,18 @@ virManageVport(const int parent_host,
> return ret;
> }
>
>+# define READ_WWN(wwn_path, buf) \
This macro either jumps to a label or alters a third variable.
I don't think its scope should extend one function.
>+ do { \
>+ if (virFileReadAll(wwn_path, 1024, &buf) < 0) \
>+ goto cleanup; \
These two lines can be split out and with the STR{,N}EQ included,
this macro can be COMPARE_WWN, removing the need for changing
p. Or turned into a more complex function like virUSBSysReadFile.
>+ if ((p = strchr(buf, '\n'))) \
>+ *p = '\0'; \
>+ if (STRPREFIX(buf, "0x")) \
>+ p = buf + strlen("0x"); \
>+ else \
>+ p = buf; \
>+ } while (0)
>+
> /* virGetFCHostNameByWWN:
> *
> * Iterate over the sysfs tree to get FC host name (e.g. host5)
The rest looks good to me.
Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170102/6099c062/attachment-0001.sig>
More information about the libvir-list
mailing list