Bug 1667329 - when create vhba without indicating wwpn/wwnn, libvirt will generate duplicated ones [rhel-7.6.z]
Summary: when create vhba without indicating wwpn/wwnn, libvirt will generate duplicat...
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: yisun
URL:
Whiteboard:
Keywords: Automation, Regression, ZStream
Depends On: 1652894
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-18 07:41 UTC by RAD team bot copy to z-stream
Modified: 2019-03-13 18:47 UTC (History)
2 users (show)

(edit)
Cause: 
An improper mathematical shift within a 64 bit space resulted in an improper and less than random value of 0 (zero).

Consequence: 
libvirt did not generate very random numbers for vHBA WWNN/WWPN pair. This also affects random UUID generation.

Fix: 
Perform proper mathematical shifts to move an unsigned long long value (64 bit) rather than just a unsigned int (32 bit) value.

Result: 
More randomly generated WWNN, WWPN, and UUID values.
Clone Of: 1652894
(edit)
Last Closed: 2019-03-13 18:47:14 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0521 None None None 2019-03-13 18:47 UTC

Description RAD team bot copy to z-stream 2019-01-18 07:41:20 UTC
This bug has been copied from bug #1652894 and has been proposed to be backported to 7.6 z-stream (EUS).

Comment 6 yisun 2019-02-22 10:29:28 UTC
[root@dell-per730-58 ~]# rpm -qa | grep libvirt-4
libvirt-4.5.0-10.virtcov.el7_6.6.x86_64


1. Code update to date
root@yisun ~/libvirt-rhel/src  ## git branch
* (detached from origin/rhel-7.6)
  rhel-7.7
root@yisun ~/libvirt-rhel/src  ## cat util/virrandom.c | grep "uint64_t virRandomBits(int nbits)" -A15
uint64_t virRandomBits(int nbits)
{
    uint64_t ret = 0;

    if (virRandomBytes((unsigned char *) &ret, sizeof(ret)) < 0) {
        /* You're already hosed, so this particular non-random value
         * isn't any worse.  */
        return 0;
    }

    if (nbits < 64)
        ret &= (1ULL << nbits) - 1;

    return ret;
}


2. Try the random number generator with scenario as comment 0
[root@dell-per730-58 ~]# cat vhba.xml 
<device><capability type="scsi_host"><capability type="fc_host"><wwnn /><wwpn /></capability></capability><parent>scsi_host11</parent></device>


[root@dell-per730-58 ~]# for i in {63..163}; do virsh nodedev-create vhba.xml >> /dev/null 2>&1; echo $i; virsh nodedev-dumpxml scsi_host$i | egrep "wwpn|wwnn"; done
63
      <wwnn>5001a4a6c3760b1f</wwnn>
      <wwpn>5001a4a985482b07</wwpn>
64
      <wwnn>5001a4a77396629a</wwnn>
      <wwpn>5001a4a4fb2a6084</wwpn>
65
      <wwnn>5001a4adf0bdaccb</wwnn>
      <wwpn>5001a4a23b1f2ada</wwpn>
66
      <wwnn>5001a4a00b4e2197</wwnn>
      <wwpn>5001a4a30058f906</wwpn>
...
162
      <wwnn>5001a4a20c9321d3</wwnn>
      <wwpn>5001a4af5f03bcce</wwpn>
163
      <wwnn>5001a4a676ad0673</wwnn>
      <wwpn>5001a4a061b2c24a</wwpn>
<==== all numbers are random, as expected

Comment 8 errata-xmlrpc 2019-03-13 18:47:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:0521


Note You need to log in before you can comment on or make changes to this bug.