[libvirt] [PATCH v2] Add virRandom() API to generate numbers with non-power-of-2 limit

2012-08-14 Thread Daniel P. Berrange
From: "Daniel P. Berrange" The current virRandomBits() API is only usable if the caller wants a random number in the range [0, (n-1)] where n is a power of two. This adds a virRandom() API which generates a double in the range [0.0,1.0] with 48 bits of entropy. It then also adds a virRandomInt(ui

Re: [libvirt] [PATCH v2] Add virRandom() API to generate numbers with non-power-of-2 limit

2012-08-14 Thread Eric Blake
On 08/14/2012 05:13 AM, Daniel P. Berrange wrote: > From: "Daniel P. Berrange" > > The current virRandomBits() API is only usable if the caller wants > a random number in the range [0, (n-1)] where n is a power of two. This one is correct (it could also be written '[0, n)'). > This adds a virRa

Re: [libvirt] [PATCH v2] Add virRandom() API to generate numbers with non-power-of-2 limit

2012-08-14 Thread Eric Blake
On 08/14/2012 05:13 AM, Daniel P. Berrange wrote: > From: "Daniel P. Berrange" > > The current virRandomBits() API is only usable if the caller wants > a random number in the range [0, (n-1)] where n is a power of two. > This adds a virRandom() API which generates a double in the > range [0.0,1.0