[libvirt] [PATCH 0/2] Fix race in qemu driver wrt vnc port allocation

Jim Fehlig jfehlig at novell.com
Mon May 17 18:09:58 UTC 2010


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.  I added them to the generic util.[ch] for
lack of a more suitable file.  Alternate suggestions welcome.  The second
patch uses the bitmap 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_auto-assignment_caveats

Jim Fehlig (2):
  Add simple bitmap operations to utils
  Fix race in finding available vnc port

 src/qemu/qemu_driver.c |   22 ++++++++++++++++++++++
 src/util/util.c        |   38 ++++++++++++++++++++++++++++++++++++++
 src/util/util.h        |   10 ++++++++++
 3 files changed, 70 insertions(+), 0 deletions(-)




More information about the libvir-list mailing list