Bug 1025407 - autoport='yes' doesn't skip over ports in use with IPv6
autoport='yes' doesn't skip over ports in use with IPv6
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Ján Tomko
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-31 11:38 EDT by Ján Tomko
Modified: 2016-04-26 11:42 EDT (History)
6 users (show)

See Also:
Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-05 02:25:30 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ján Tomko 2013-10-31 11:38:09 EDT
Description of problem:
autoport='yes' doesn't skip over ports in use with IPv6

Version-Release number of selected component (if applicable):
libvirt-1.1.1-10.el7

How reproducible:
100%

Steps to Reproduce:
1. Listen on IPv6-only on the first display port without libvirtd's knowlege. Either:
a) start a domain with <graphics listen="::1" autoport="yes">
and restart libvirtd
or b) nc -6 -l -p 5900
2. Try to start another domain with <graphics listen="::1" autoport="yes">

Actual results:
error: Failed to start domain f19live
error: internal error: process exited while connecting to monitor: ((null):15085): Spice-Warning **: reds.c:3037:reds_init_socket: reds_init_socket: binding socket to ::1:5900 failed
qemu-kvm: failed to initialize spice server

Expected results:
Another port is assigned and domain starts successfully.

Additional info:
v1 of the patches proposed upstream:
https://www.redhat.com/archives/libvir-list/2013-October/msg00007.html
Comment 2 Ján Tomko 2013-10-31 11:41:11 EDT
v2 posted upstream:
https://www.redhat.com/archives/libvir-list/2013-October/msg01313.html
Comment 4 Ján Tomko 2014-02-14 07:53:16 EST
v3 of the patchset:
https://www.redhat.com/archives/libvir-list/2014-February/msg00325.html

Now pushed upstream:
commit 0ee9081215be8a11a5b31c5442b039d12466a0ae
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2014-02-14 13:18:35 +0100

    Support IPv6 in port allocator
    
    Also try to bind on IPv6 to check if the port is occupied.
    
    Change the mocked bind in the test to return EADDRINUSE
    for some ports only for the IPv4/IPv6 socket if we're testing
    on a host with IPv6 compiled in.
    
    Also mock socket() to make it fail with EAFNOTSUPPORTED
    if LIBVIRT_TEST_IPV4ONLY is set in the environment, to
    simulate a host without IPv6 support in the kernel. The
    tests are repeated again with this variable set.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1025407

commit 531bc0bbd049a22141af98e833abe8acfd610585
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2014-02-14 13:18:35 +0100

    Split out bind() from virPortAllocatorAcquire

git describe: v1.2.1-213-g0ee9081
Comment 7 Luyao Huang 2014-11-19 21:28:37 EST
I can reproduce this bug with libvirt-1.1.1-29.el7.x86_64:

# virsh dumpxml etsd|grep ::1
    <graphics type='spice' port='5900' autoport='yes' listen='::1'>
      <listen type='address' address='::1'/>
# virsh dumpxml etsd2|grep ::1
    <graphics type='spice' autoport='yes' listen='::1'>
      <listen type='address' address='::1'/>

# virsh start etsd
Domain etsd started


# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh start etsd2
error: Failed to start domain etsd2
error: internal error: process exited while connecting to monitor: ((null):16242): Spice-Warning **: reds.c:3070:reds_init_socket: reds_init_socket: binding socket to ::1:5900 failed
qemu-kvm: failed to initialize spice server

And verify this bug with libvirt-1.2.8-7.el7.x86_64 :

# virsh dumpxml etsd|grep ::1
    <graphics type='spice' port='5900' autoport='yes' listen='::1'>
      <listen type='address' address='::1'/>
# virsh dumpxml etsd2|grep ::1
    <graphics type='spice' autoport='yes' listen='::1'>
      <listen type='address' address='::1'/>

# virsh start etsd
Domain etsd started

# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh start etsd2
Domain etsd2 started

Also test with vnc.
Comment 8 Luyao Huang 2014-11-19 21:30:36 EST
Forgot this :

# virsh start etsd2
Domain etsd2 started

# netstat -ntap|grep qemu
tcp6       0      0 ::1:5900                :::*                    LISTEN      17671/qemu-kvm      
tcp6       0      0 ::1:5901                :::*                    LISTEN      17805/qemu-kvm
Comment 10 errata-xmlrpc 2015-03-05 02:25:30 EST
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://rhn.redhat.com/errata/RHSA-2015-0323.html

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