Class: VagrantPlugins::QEMU::Network::Socket

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant-qemu/network/socket.rb

Overview

QEMU ‘socket` netdev backend – a thin wrapper, not an abstraction.

Whatever the user puts in ‘socket_opts` is emitted verbatim as the netdev options, so the mode is entirely the user’s choice:

socket_opts: "mcast=230.0.0.1:1234"   -> multicast, N-way (Linux/Windows)
socket_opts: "listen=:1234"           -> point-to-point, this VM listens
socket_opts: "connect=127.0.0.1:1234" -> point-to-point, this VM connects

For listen/connect the user decides which VM listens and which connects; the plugin does not assign roles. (listen/connect is the no-root, macOS-friendly path; mcast does not work on macOS.)

When ‘socket_opts` is unset it falls back to multicast using `mcast_addr` (default 230.0.0.1:1234) for backward compatibility.

Instance Method Summary collapse

Methods inherited from Base

#requires_sudo?

Instance Method Details

#build_netdev_args(id, options) ⇒ Object



20
21
22
23
24
# File 'lib/vagrant-qemu/network/socket.rb', line 20

def build_netdev_args(id, options)
  opts = options[:socket_opts]
  opts = "mcast=#{options[:mcast_addr] || "230.0.0.1:1234"}" if opts.nil? || opts.empty?
  %W(-netdev socket,id=#{id},#{opts})
end