Sorry for the delay ... V2 changes noted in the patches.
The qemu driver contains a subtle race in the logic to find next
available vnc port. Currently it iterates through all available ports
and returns the first for which bind(2) succeeds. However it is possible
that a previously issued port has not yet been bound by qemu, resulting
in the same port used for a subsequent domain.
The issue was briefly discussed on IRC and the consensus there was to
track port allocation with a bitmap. The first patch adds some simple
bitmap operations to utils. Second patch defines VNC_PORT_{MIN,MAX} and
uses them in place of explicit values. Third patch makes use of the
bitmap impl to track vnc port allocations.
The race was consistently encountered in HA environments [1]. This patch
series has been successfully tested in such environment.
[1]
http://www.linux-ha.org/wiki/VirtualDomain_%28resource_agent%29#VNC_port_...
Jim Fehlig (3):
Add simple bitmap operations to utils
Add defines for QEMU_VNC_PORT_{MIN,MAX} and use them
Fix race in finding available vnc port
cfg.mk | 1 +
src/Makefile.am | 1 +
src/libvirt_private.syms | 8 +++
src/qemu/qemu_conf.h | 3 +
src/qemu/qemu_driver.c | 39 +++++++++++-
src/util/bitmap.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/bitmap.h | 60 ++++++++++++++++++
7 files changed, 264 insertions(+), 3 deletions(-)
create mode 100644 src/util/bitmap.c
create mode 100644 src/util/bitmap.h