Re: [libvirt] [PATCH 6/8] Add unique_id to nodedev output

2014-06-11 Thread Daniel P. Berrange
On Tue, Jun 10, 2014 at 03:03:55PM -0400, John Ferlan wrote:
 Add an optional unique_id parameter to nodedev.  Allows for easier lookup
 and display of the unique_id value in order to document for use with
 scsi_host code.
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  docs/formatnode.html.in| 11 +++
  docs/schemas/nodedev.rng   |  6 ++
  src/conf/node_device_conf.c| 23 
 --
  src/conf/node_device_conf.h|  1 +
  src/node_device/node_device_linux_sysfs.c  |  6 ++
  src/test/test_driver.c |  5 +++--
  .../pci_8086_27c5_scsi_host_0_unique_id.xml|  8 
  tests/nodedevxml2xmltest.c |  1 +
  8 files changed, 53 insertions(+), 8 deletions(-)
  create mode 100644 
 tests/nodedevschemadata/pci_8086_27c5_scsi_host_0_unique_id.xml
 
 diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
 index 76bf8af..cdf0277 100644
 --- a/docs/formatnode.html.in
 +++ b/docs/formatnode.html.in
 @@ -173,6 +173,17 @@
  dl
dtcodehost/code/dt
ddThe SCSI host number./dd
 +  dtcodeunique_id/code/dt
 +  ddOn input, this optionally provides the value from the
 +'unique_id' file found in the scsi_host's directory. To
 +view the values of all 'unique_id' files, use codefind -H
 +/sys/class/scsi_host/host{0..9}/unique_id |
 +xargs grep '[0-9]'/code. On output, if the unique_id
 +file exists, the value from the file will be displayed.
 +This can be used in order to help uniquely identify the
 +scsi_host adapter in a a href=formatstorage.html
 +Storage Pool/a. span class=sinceSince 1.2.6/span
 +  /dd

Where is the data from the 'unique_id' coming from ? Is this since that
Linux makes up, or is it some standard attribute from the hardware ? It
would be desirable to document what it is in a way that's not simply
refering to Linux sysfs, since sysfs itself is mostly undocumented :-)


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 6/8] Add unique_id to nodedev output

2014-06-11 Thread John Ferlan


On 06/11/2014 05:31 AM, Daniel P. Berrange wrote:
 On Tue, Jun 10, 2014 at 03:03:55PM -0400, John Ferlan wrote:
 Add an optional unique_id parameter to nodedev.  Allows for easier lookup
 and display of the unique_id value in order to document for use with
 scsi_host code.

 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  docs/formatnode.html.in| 11 +++
  docs/schemas/nodedev.rng   |  6 ++
  src/conf/node_device_conf.c| 23 
 --
  src/conf/node_device_conf.h|  1 +
  src/node_device/node_device_linux_sysfs.c  |  6 ++
  src/test/test_driver.c |  5 +++--
  .../pci_8086_27c5_scsi_host_0_unique_id.xml|  8 
  tests/nodedevxml2xmltest.c |  1 +
  8 files changed, 53 insertions(+), 8 deletions(-)
  create mode 100644 
 tests/nodedevschemadata/pci_8086_27c5_scsi_host_0_unique_id.xml

 diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
 index 76bf8af..cdf0277 100644
 --- a/docs/formatnode.html.in
 +++ b/docs/formatnode.html.in
 @@ -173,6 +173,17 @@
  dl
dtcodehost/code/dt
ddThe SCSI host number./dd
 +  dtcodeunique_id/code/dt
 +  ddOn input, this optionally provides the value from the
 +'unique_id' file found in the scsi_host's directory. To
 +view the values of all 'unique_id' files, use codefind -H
 +/sys/class/scsi_host/host{0..9}/unique_id |
 +xargs grep '[0-9]'/code. On output, if the unique_id
 +file exists, the value from the file will be displayed.
 +This can be used in order to help uniquely identify the
 +scsi_host adapter in a a href=formatstorage.html
 +Storage Pool/a. span class=sinceSince 1.2.6/span
 +  /dd
 
 Where is the data from the 'unique_id' coming from ? Is this since that
 Linux makes up, or is it some standard attribute from the hardware ? It
 would be desirable to document what it is in a way that's not simply
 refering to Linux sysfs, since sysfs itself is mostly undocumented :-)
 
 

Using 'unique_id' was from Osier's initial design - I 'assumed' that his
research into this had determined using this was unique enough.

A small amount of searching turns this up:

https://lkml.org/lkml/2011/8/17/274
...
+What:  /sys/bus/scsi/devices/host*/scsi_host/host*/unique_id
+Date:  February, 2003
+KernelVersion: Unknown
+Contact:   James Bottomley james.bottom...@hansenpartnership.com
+Description:
+   Read only unsigned integer uniquely identifying the SCSI host
+   within the system.  This value is assigned by the low level
+   driver.
+
...


Also from various sources, there's '/linux/include/scsi/scsi_host.h

/*
 * This is a unique identifier that must be assigned so that we
 * have some way of identifying each detected host adapter properly
 * and uniquely.  For hosts that do not support more than one card
 * in the system at one time, this does not need to be set.  It is
 * initialized to 0 in scsi_register.
 */
unsigned int unique_id;

 Regards,
 Daniel
 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 6/8] Add unique_id to nodedev output

2014-06-11 Thread Daniel P. Berrange
On Wed, Jun 11, 2014 at 10:00:24AM -0400, John Ferlan wrote:
 
 
 On 06/11/2014 05:31 AM, Daniel P. Berrange wrote:
  On Tue, Jun 10, 2014 at 03:03:55PM -0400, John Ferlan wrote:
  Add an optional unique_id parameter to nodedev.  Allows for easier lookup
  and display of the unique_id value in order to document for use with
  scsi_host code.
 
  Signed-off-by: John Ferlan jfer...@redhat.com
  ---
   docs/formatnode.html.in| 11 +++
   docs/schemas/nodedev.rng   |  6 ++
   src/conf/node_device_conf.c| 23 
  --
   src/conf/node_device_conf.h|  1 +
   src/node_device/node_device_linux_sysfs.c  |  6 ++
   src/test/test_driver.c |  5 +++--
   .../pci_8086_27c5_scsi_host_0_unique_id.xml|  8 
   tests/nodedevxml2xmltest.c |  1 +
   8 files changed, 53 insertions(+), 8 deletions(-)
   create mode 100644 
  tests/nodedevschemadata/pci_8086_27c5_scsi_host_0_unique_id.xml
 
  diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
  index 76bf8af..cdf0277 100644
  --- a/docs/formatnode.html.in
  +++ b/docs/formatnode.html.in
  @@ -173,6 +173,17 @@
   dl
 dtcodehost/code/dt
 ddThe SCSI host number./dd
  +  dtcodeunique_id/code/dt
  +  ddOn input, this optionally provides the value from the
  +'unique_id' file found in the scsi_host's directory. To
  +view the values of all 'unique_id' files, use codefind 
  -H
  +/sys/class/scsi_host/host{0..9}/unique_id |
  +xargs grep '[0-9]'/code. On output, if the unique_id
  +file exists, the value from the file will be displayed.
  +This can be used in order to help uniquely identify the
  +scsi_host adapter in a a href=formatstorage.html
  +Storage Pool/a. span class=sinceSince 1.2.6/span
  +  /dd
  
  Where is the data from the 'unique_id' coming from ? Is this since that
  Linux makes up, or is it some standard attribute from the hardware ? It
  would be desirable to document what it is in a way that's not simply
  refering to Linux sysfs, since sysfs itself is mostly undocumented :-)
  
  
 
 Using 'unique_id' was from Osier's initial design - I 'assumed' that his
 research into this had determined using this was unique enough.
 
 A small amount of searching turns this up:
 
 https://lkml.org/lkml/2011/8/17/274
 ...
 +What:/sys/bus/scsi/devices/host*/scsi_host/host*/unique_id
 +Date:February, 2003
 +KernelVersion:   Unknown
 +Contact: James Bottomley james.bottom...@hansenpartnership.com
 +Description:
 + Read only unsigned integer uniquely identifying the SCSI host
 + within the system.  This value is assigned by the low level
 + driver.
 +
 ...
 
 
 Also from various sources, there's '/linux/include/scsi/scsi_host.h
 
 /*
  * This is a unique identifier that must be assigned so that we
  * have some way of identifying each detected host adapter properly
  * and uniquely.  For hosts that do not support more than one card
  * in the system at one time, this does not need to be set.  It is
  * initialized to 0 in scsi_register.
  */
 unsigned int unique_id;

Hmm, that's all rather fuzzy.  I wonder how much better this is unique
int ID is than the current hostNN numbers. eg is this unique id stable
when you plug / unplug iSCSI targets in arbitrary order

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 6/8] Add unique_id to nodedev output

2014-06-11 Thread John Ferlan


On 06/11/2014 10:10 AM, Daniel P. Berrange wrote:
 On Wed, Jun 11, 2014 at 10:00:24AM -0400, John Ferlan wrote:


 On 06/11/2014 05:31 AM, Daniel P. Berrange wrote:
 On Tue, Jun 10, 2014 at 03:03:55PM -0400, John Ferlan wrote:

 Where is the data from the 'unique_id' coming from ? Is this since that
 Linux makes up, or is it some standard attribute from the hardware ? It
 would be desirable to document what it is in a way that's not simply
 refering to Linux sysfs, since sysfs itself is mostly undocumented :-)



 Using 'unique_id' was from Osier's initial design - I 'assumed' that his
 research into this had determined using this was unique enough.

 A small amount of searching turns this up:

 https://lkml.org/lkml/2011/8/17/274
 ...
 +What:   /sys/bus/scsi/devices/host*/scsi_host/host*/unique_id
 +Date:   February, 2003
 +KernelVersion:  Unknown
 +Contact:James Bottomley james.bottom...@hansenpartnership.com
 +Description:
 +Read only unsigned integer uniquely identifying the SCSI host
 +within the system.  This value is assigned by the low level
 +driver.
 +
 ...


 Also from various sources, there's '/linux/include/scsi/scsi_host.h

 /*
  * This is a unique identifier that must be assigned so that we
  * have some way of identifying each detected host adapter properly
  * and uniquely.  For hosts that do not support more than one card
  * in the system at one time, this does not need to be set.  It is
  * initialized to 0 in scsi_register.
  */
 unsigned int unique_id;
 
 Hmm, that's all rather fuzzy.  I wonder how much better this is unique
 int ID is than the current hostNN numbers. eg is this unique id stable
 when you plug / unplug iSCSI targets in arbitrary order
 

Not sure I can answer with authority on the plug/unplug topic; however,
as I understand it the hostNN numbers can change what they are
pointing at after perhaps a reboot or scsi kernel module reload.  I'm
not an expert in these matters, but as I do understand it hardware is
scanned and devices named in the order they are found.

Using the PCI address and unique_id in combination provides a bit more
of a chance that if the hostNN number changes, then libvirt will/could
find the same adapter that was previously used.

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 6/8] Add unique_id to nodedev output

2014-06-10 Thread John Ferlan
Add an optional unique_id parameter to nodedev.  Allows for easier lookup
and display of the unique_id value in order to document for use with
scsi_host code.

Signed-off-by: John Ferlan jfer...@redhat.com
---
 docs/formatnode.html.in| 11 +++
 docs/schemas/nodedev.rng   |  6 ++
 src/conf/node_device_conf.c| 23 --
 src/conf/node_device_conf.h|  1 +
 src/node_device/node_device_linux_sysfs.c  |  6 ++
 src/test/test_driver.c |  5 +++--
 .../pci_8086_27c5_scsi_host_0_unique_id.xml|  8 
 tests/nodedevxml2xmltest.c |  1 +
 8 files changed, 53 insertions(+), 8 deletions(-)
 create mode 100644 
tests/nodedevschemadata/pci_8086_27c5_scsi_host_0_unique_id.xml

diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index 76bf8af..cdf0277 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -173,6 +173,17 @@
 dl
   dtcodehost/code/dt
   ddThe SCSI host number./dd
+  dtcodeunique_id/code/dt
+  ddOn input, this optionally provides the value from the
+'unique_id' file found in the scsi_host's directory. To
+view the values of all 'unique_id' files, use codefind -H
+/sys/class/scsi_host/host{0..9}/unique_id |
+xargs grep '[0-9]'/code. On output, if the unique_id
+file exists, the value from the file will be displayed.
+This can be used in order to help uniquely identify the
+scsi_host adapter in a a href=formatstorage.html
+Storage Pool/a. span class=sinceSince 1.2.6/span
+  /dd
   dtcodecapability/code/dt
   ddCurrent capabilities include vports_ops (indicates
 vport operations are supported) and fc_host. vport_ops
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 02d4106..31319da 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -310,6 +310,12 @@
 /element
 
 optional
+  element name='unique_id'
+ref name='positiveInteger'/
+  /element
+/optional
+
+optional
   zeroOrMore
 element name='capability'
   choice
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 99fa448..e73a9f4 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -399,6 +399,9 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
 case VIR_NODE_DEV_CAP_SCSI_HOST:
 virBufferAsprintf(buf, host%d/host\n,
   data-scsi_host.host);
+if (data-scsi_host.unique_id != -1)
+virBufferAsprintf(buf, unique_id%d/unique_id\n,
+  data-scsi_host.unique_id);
 if (data-scsi_host.flags  VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
 virBufferAddLit(buf, capability type='fc_host'\n);
 virBufferAdjustIndent(buf, 2);
@@ -788,12 +791,20 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt,
 orignode = ctxt-node;
 ctxt-node = node;
 
-if (create == EXISTING_DEVICE 
-virNodeDevCapsDefParseULong(number(./host[1]), ctxt,
-data-scsi_host.host, def,
-_(no SCSI host ID supplied for '%s'),
-_(invalid SCSI host ID supplied for 
'%s'))  0) {
-goto out;
+if (create == EXISTING_DEVICE) {
+if (virNodeDevCapsDefParseULong(number(./host[1]), ctxt,
+data-scsi_host.host, def,
+_(no SCSI host ID supplied for '%s'),
+_(invalid SCSI host ID supplied for 
'%s'))  0) {
+goto out;
+}
+/* Optional unique_id value */
+data-scsi_host.unique_id = -1;
+if (virNodeDevCapsDefParseIntOptional(number(./unique_id[1]), ctxt,
+  data-scsi_host.unique_id, def,
+  _(invalid unique_id supplied 
for '%s'))  0) {
+goto out;
+}
 }
 
 if ((n = virXPathNodeSet(./capability, ctxt, nodes))  0) {
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 50ce4b3..e949d93 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -140,6 +140,7 @@ struct _virNodeDevCapsDef {
 } net;
 struct {
 unsigned int host;
+int unique_id;
 char *wwnn;
 char *wwpn;
 char *fabric_wwn;
diff --git a/src/node_device/node_device_linux_sysfs.c 
b/src/node_device/node_device_linux_sysfs.c
index 6d9726f..be95e51 100644
---