Bug 1591645 - Spice port 65536 is converted to 0
Summary: Spice port 65536 is converted to 0
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: 8.0
Assignee: Ján Tomko
QA Contact: yanqzhan@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-15 08:16 UTC by Fangge Jin
Modified: 2019-11-06 07:11 UTC (History)
6 users (show)

Fixed In Version: libvirt-5.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-06 07:11:37 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)
reproduce-logs_comment5 (68.71 KB, application/x-gzip)
2018-08-09 11:37 UTC, yanqzhan@redhat.com
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:3723 None None None 2019-11-06 07:11:52 UTC

Description Fangge Jin 2018-06-15 08:16:32 UTC
Description of problem:
Spice port 65536 is converted to 1

Version-Release number of selected component (if applicable):
libvirt-4.4.0-2.virtcov.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Set spice port to 65536 in domain xml:
    <graphics type='spice' port='65536' autoport='no'/>

2.Start guest
# virsh start rhel7.5
error: Failed to start domain rhel7.5
error: internal error: Failed to reserve port 0

Actual results:
Guest fails to start, but the error message is not correct

Expected results:
# virsh start rhel7.5
error: Failed to start domain rhel7.5
error: internal error: qemu unexpectedly closed the monitor: 2018-06-15T08:15:33.094481Z qemu-kvm: spice port is out of range

Comment 3 Ján Tomko 2018-07-02 15:27:15 UTC
Current git version of libvirt no longer shows the incorrect error message, fixed by:
commit 5e828d03bf662331579c24677d29e50b9bc33951
Author:     Pavel Hrdina <phrdina@redhat.com>
AuthorDate: 2018-06-14 09:17:10 +0200
Commit:     Pavel Hrdina <phrdina@redhat.com>
CommitDate: 2018-06-14 09:52:21 +0200

    virtportallocator: Change number of ports to 65536
    
    USHRT_MAX is not good enough because the value is 65535 which specifies
    the number of bits in bitmap.  The allowed port range is 0-65535 so we
    need to increase the number.
    
    We could have USHRT_MAX + 1 but let's define the number explicitly.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1590214
    
    Reviewed-by: Ján Tomko <jtomko@redhat.com>
    Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

git describe: v4.4.0-247-g5e828d03bf contains: v4.5.0-rc1~115

Comment 5 yanqzhan@redhat.com 2018-08-09 11:32:00 UTC
Issue still exists:
libvirt-4.5.0-6.el7.x86_64
qemu-kvm-rhev-2.12.0-9.el7.x86_64

Description:
 Spice port 65536 is converted to 0 unless after a fresh libvirtd restart

Steps:
1.Define a guest with spice graphic port='65536':
    <graphics type='spice' port='65536' autoport='no'/>

2.Try to start the guest:
# virsh start yan-V
error: Failed to start domain yan-V
error: internal error: Failed to reserve port 0

3.Restart libvirtd and try to start the guest again and again:
# systemctl restart libvirtd

# virsh start yan-V
error: Failed to start domain yan-V
error: internal error: qemu unexpectedly closed the monitor: 2018-08-09T11:10:33.509086Z qemu-kvm: spice port is out of range

# virsh start yan-V
error: Failed to start domain yan-V
error: internal error: Failed to reserve port 0

# virsh start yan-V
error: Failed to start domain yan-V
error: internal error: Failed to reserve port 0
...

Actual results:
Guest starts failed, always get error "Failed to reserve port 0", except restart a fresh libvirtd, the error "spice port is out of range" will show once.

More details pls refer to "reproduce-logs" in attachment.

Comment 6 yanqzhan@redhat.com 2018-08-09 11:37:00 UTC
Created attachment 1474654 [details]
reproduce-logs_comment5

Comment 10 Ján Tomko 2019-01-21 15:01:23 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2019-January/msg00715.html

Comment 11 Ján Tomko 2019-01-25 13:53:22 UTC
commit c2a8256991d772323a3df08c33b012bf12d62645
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2019-01-25 14:50:05 +0100

    virPortAllocatorSetUsed: ignore port 0
    
    Similar to what commit 86dba8f3 did for virPortAllocatorRelease,
    ignore port 0 in virPortAllocatorSetUsed.
    
    For all the reasonable use cases the callers already check that
    the port is non-zero, however if the port from the XML overflows
    unsigned short and turns into 0, it can be set as used by
    virPortAllocatorSetUsed but not released by virPortAllocatorRelease.
    
    Also skip port '0' in virPortAllocatorSetUsed to make this behavior
    symmetric.
    
    The serenity was disturbed by commit 5dbda5e9 which started using
    virPortAllocatorRelease instead of virPortAllocatorSetUsed (false).
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1591645
    
    Signed-off-by: Ján Tomko <jtomko@redhat.com>
    Reviewed-by: Cole Robinson <crobinso@redhat.com>

git describe: v5.0.0-109-gc2a8256991

Comment 15 yanqzhan@redhat.com 2019-07-31 11:37:26 UTC
Verify this bug with:
libvirt-daemon-5.5.0-2.module+el8.1.0+3773+7dd501bf.x86_64
qemu-kvm-4.0.0-6.module+el8.1.0+3736+a2aefea3.x86_64

Steps:
Scenario 1: spice port testing
1.    <graphics type='spice' port='65536' autoport='no'>
      <listen type='address'/>
    </graphics>

# virsh start avocado-vt-vm1
error: Failed to start domain avocado-vt-vm1
error: internal error: process exited while connecting to monitor: 2019-07-31T10:48:45.888568Z qemu-kvm: spice port is out of range

# systemctl restart libvirtd 

# virsh start avocado-vt-vm1
error: Failed to start domain avocado-vt-vm1
error: internal error: process exited while connecting to monitor: 2019-07-31T10:49:04.275179Z qemu-kvm: spice port is out of range

2.  <graphics type='spice' port='0' autoport='no'/>

# virsh dumpxml avocado-vt-vm1 --inactive |grep graphic -1
    <graphics type='spice'>
      <listen type='none'/>
    </graphics>

# virsh start avocado-vt-vm1 
Domain avocado-vt-vm1 started

# virsh dumpxml avocado-vt-vm1  |grep graphic -1
    <graphics type='spice'>
      <listen type='none'/>
    </graphics>

3.    <graphics type='spice' port='65535' autoport='no'>
      <listen type='address'/>
    </graphics>

# virsh start avocado-vt-vm1 
Domain avocado-vt-vm1 started

# virsh dumpxml avocado-vt-vm1  |grep graphic -1
    </input>
    <graphics type='spice' port='65535' autoport='no' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>

4.    <graphics type='spice' port='-1' autoport='no'>
      <listen type='address'/>
    </graphics>

# virsh start avocado-vt-vm1 
Domain avocado-vt-vm1 started

# virsh dumpxml avocado-vt-vm1 |grep graphic -1
    <graphics type='spice' port='5900' autoport='no' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>

5.    <graphics type='spice' port='5902' autoport='no'>
      <listen type='address'/>
    </graphics>

# virsh start avocado-vt-vm1 
Domain avocado-vt-vm1 started

# virsh dumpxml avocado-vt-vm1  |grep graphic -1
    <graphics type='spice' port='5902' autoport='no' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>

Scenario 2: spice tls-port testing
1.
   <graphics type='spice' port='5901' tlsPort='65536' autoport='no'>
      <listen type='address'/>
    </graphics>

# vim /etc/libvirt/qemu.conf
spice_tls = 1

# systemctl restart libvirtd

# virsh start avocado-vt-vm1 
error: Failed to start domain avocado-vt-vm1
error: internal error: process exited while connecting to monitor: 2019-07-31T11:10:51.170585Z qemu-kvm: spice tls-port is out of range

2.    <graphics type='spice' port='5901' tlsPort='0' autoport='no'/>

#  virsh dumpxml avocado-vt-vm1  |grep graphic -1
    <graphics type='spice' port='5901' autoport='no'>
      <listen type='address'/>
    </graphics>

# virsh start avocado-vt-vm1 
Domain avocado-vt-vm1 started

#  virsh dumpxml avocado-vt-vm1  |grep graphic -1
    <graphics type='spice' port='5901' autoport='no' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>

Comment 17 errata-xmlrpc 2019-11-06 07:11:37 UTC
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://access.redhat.com/errata/RHBA-2019:3723


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