Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1209959

Summary: Cannot start multiple guests with VNC monitor listening on same port (different address)
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Jiri Lunacek <jiri.lunacek>
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED DEFERRED QA Contact: Yanqiu Zhang <yanqzhan>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 8.0CC: dyuan, fjin, mprivozn, mzhan, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-10 13:15:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to disable port allocator for qemu VNC display none

Description Jiri Lunacek 2015-04-08 14:06:30 UTC
Description of problem:
When two KVM guests have VNC monitor defined to listen on different address but on same port creation of other than the first guest fails with "Failed to reserve port 5900".

Version-Release number of selected component (if applicable):
1.2.8-16.el7_1.2.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Add two different addresses to some interface eg:
 # ip ad add 127.0.1.1/8 dev lo
 # ip ad add 127.0.1.2/8 dev lo
2. Create two KVM guests using these addresses and port 5900 for VNC monitor. eg:
...
    <graphics type='vnc' port='5900' autoport='no' listen='127.0.1.1' passwd='1SsGxoKT'>
      <listen type='address' address='127.0.1.1'/>
    </graphics>
...
3. Start first guest
4. Start second guest

Actual results:
When trying to start the second guest, libvirt fails with:
error: Failed to start domain
error: internal error: Failed to reserve port 5900

Expected results:
Both guests start

Additional info:
The actual bug seems to be that virportallocator does not deal with the situation that user specifies listen address for the vnc monitor.
I dug a litle into this and found changes in src/util/virportallocator.c between 7.0 and 7.1 release caused this.
The bug existed before, it was only skipped when the socket could be binded successfully.

IMHO the easiest fix would be to ignore "duplicate" port reservations provided that the socket is free and bindable. I am not sure if that breaks automatic assignment of ports or something else though.

This may be related to #1081881

Comment 2 Pavel Hrdina 2015-07-15 13:27:57 UTC
Moving to RHEL-7.3, it's not a critical bug.

Comment 7 Jiri Lunacek 2019-01-09 10:03:45 UTC
Created attachment 1519421 [details]
Patch to disable port allocator for qemu VNC display

Comment 8 Jiri Lunacek 2019-01-09 10:05:27 UTC
This prevails in 7.6 even though virPortAllocator has been rewritten in libvirt 4.5

I have added a patch that adds a configuration option to disable port allocation bitmap for qemu VNC.

Comment 9 Michal Privoznik 2019-09-16 06:00:04 UTC
There's an upstream reincarnation of this bug - see bug 1751969.

I'll just repeat here what I said there - the only possible fix that would work is if libvirt would bind() to the address + port itself and then just passed FD to qemu.

Comment 10 Pavel Hrdina 2020-03-10 13:15:52 UTC
This bug was closed deferred as a result of bug triage.

Please reopen if you disagree and provide justification why this bug should
get enough priority. Most important would be information about impact on
customer or layered product. Please indicate requested target release.