qemu 5.1.0: Add UNIX socket support for netdev socket

Bug #1903470 reported by Mark Karpelès
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
QEMU
Expired
Undecided
Unassigned

Bug Description

Note: this is a feature request.

qemu has a way to connect instances using a socket:

-netdev socket,id=str[,fd=h][,listen=[host]:port][,connect=host:port]

This can also be used to connect a qemu instance to something else using a socket connection, however there is no authentication or security to the connection, so rather than using a port which can be accessed by any user on the machine, having the ability to use or connect to UNIX sockets would be helpful, and adding this option should be fairly trivial.

UNIX sockets can be found in various parts of qemu (monitor, etc) so I believe having this on network would make sense.

description: updated
Revision history for this message
elmarco (marcandre-lureau) wrote :

With the fd= argument/property, you can setup a private socketpair connection already. Is this enough?

Thomas Huth (th-huth)
Changed in qemu:
status: New → Incomplete
Revision history for this message
Mark Karpelès (magicaltux) wrote :

Thanks for the response. I'm not sure, how would I run qemu with a fd= socketpair on the command line?

The wiki (https://wiki.qemu.org/index.php/Documentation/Networking) suggests for example to use:

-netdev socket,id=mynet0,listen=:1234
-netdev socket,id=mynet0,connect=:1234

This would allow however anyone on the same network (or in the world if run on a server) to connect to this network and possibly do bad things. Using localhost binding helps but is still risky if there is more than one user on a given machine. Using something like:

-netdev socket,id=mynet0,listen=~/.qemu-netsocket
-netdev socket,id=mynet0,connect=~/.qemu-netsocket

How would one do that with fd= ?

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for QEMU because there has been no activity for 60 days.]

Changed in qemu:
status: Incomplete → Expired
Revision history for this message
Yury Bushmelev (jay7x) wrote :

JFYI I miss the ability to use Unix socket right now.. I'm trying to use vagrant + vagrant-qemu + socket_vmnet on Macbook m1. It'd be MUCH easier to connect QEMU to the socket_vmnet' Unix socket directly w/o any wrappers..

Revision history for this message
Laurent Vivier (laurent-vivier) wrote :

This will be available in the next QEMU release (7.2) under a sligthly different form:

"-netdev stream" for TCP socket and "-netdev dgram" for UDP socket.

Both support inet and unix sockets. See qemu(1).

Revision history for this message
Laurent Vivier (laurent-vivier) wrote :

This was added to support passt:

https://passt.top

Revision history for this message
Mark Karpelès (magicaltux) wrote :

Despite what is said in an earlier comment, qemu(1) has no information on -netdev stream or -netdev dgram.

The best help I could find comes from the patch description:

https://<email address hidden>/

Example use:

-netdev stream,id=socket0,server=off,addr.type=unix,addr.path=/tmp/qemu0

Also useful to note that the reconnect argument is only going to be available in qemu 8.0.0 (not released yet)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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