VNC unix-domain socket unlink()ed prematurely

Bug #1795100 reported by LukeShu
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Unassigned

Bug Description

With qemu 3.0.0 (I don't believe this happened with previous
versions), if I tell it `-vnc unix:/path/to/vnc.sock`, qemu will
unlink() that file when the first client disconnects, meaning that
once I disconnect, I can't ever reconnect without restarting the VM.

A stupid testcase demonstrating the issue:

In terminal A:

    $ qemu-system-x86_64 -vnc unix:$PWD/vnc.sock

In terminal B:

    $ ls vnc.sock
    vnc.sock
    $ socat STDIO UNIX-CONNECT:vnc.sock <<<''
    RFB 003.008
    $ ls vnc.sock
    ls: cannot access 'vnc.sock': No such file or directory

I have determined that the offending unlink() call is the one in
io/channel-socket.c:qio_channel_socket_close(). That call was first
introduced in commit d66f78e1eaa832f73c771d9df1b606fe75d52a50, which
first appeared in version 3.0.0.

This type of premature unlink() does not happen on monitor.sock with
`-monitor unix:/path/to/monitor.sock,server,nowait`.

I am not familiar enough with the QIO subsystem to suggest a fix that
fixes VNC, but preserves the QMP fix targeted in the offending commit.

Revision history for this message
LukeShu (lukeshu) wrote :

This is still a problem with 3.1.0.

summary: - unix-domain socket unlink()ed prematurely
+ VNC unix-domain socket unlink()ed prematurely
Revision history for this message
Dr. David Alan Gilbert (dgilbert-h) wrote :

Added Daniel to the bug.

Revision history for this message
Daniel Berrange (berrange) wrote :

It only affects VNC, not chardevs because the chardevs fail to call qio_channel_close() and just rely on finalize() cleaning up the open socket. To fix this we just need to made the code conditional on it being a listener socket

  if (qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_LISTEN)) {
   ...
  }

Revision history for this message
Daniel Berrange (berrange) wrote :
Revision history for this message
Daniel Berrange (berrange) wrote :
Changed in qemu:
status: New → Fix Committed
Thomas Huth (th-huth)
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.