util: avoid getting stuck on macvtapN name created outside libvirt

After the patches that added tracking of in-use macvtap names (commit
370608, first appearing in libvirt-1.3.2), if the function to allocate
a new macvtap device came to a device name created outside libvirt, it
would retry the same device name MACVLAN_MAX_ID (8191) times before
finally giving up in failure.

The problem was that virBitmapNextClearBit was always being called
with "0" rather than the value most recently checked (which would
increment each time through the loop), so it would always return the
same id (since we dutifully release that id after failing to create a
new device using it).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1321546

Signed-off-by: Laine Stump <laine@laine.org>
This commit is contained in:
Laine Stump 2016-03-28 10:14:04 -04:00
parent 373b9e9f00
commit 5b5f12cffa
1 changed files with 1 additions and 1 deletions

View File

@ -131,7 +131,7 @@ virNetDevMacVLanReserveID(int id, unsigned int flags,
}
if ((id < 0 || nextFree) &&
(id = virBitmapNextClearBit(bitmap, 0)) < 0) {
(id = virBitmapNextClearBit(bitmap, id)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no unused %s names available"),
(flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?