Skip to content

Commit 0913c3b

Browse files
committed
Remove the support for vde_vmnet (Deprecated since Sep 2022)
`vde_vmnet` has been deprecated since Lima v0.12.0 (Sep 2022), in favor of `socket_vmnet`: - PR 851 Signed-off-by: Akihiro Suda <[email protected]>
1 parent 6bbd9a7 commit 0913c3b

File tree

19 files changed

+30
-318
lines changed

19 files changed

+30
-318
lines changed

examples/default.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ networks:
319319
# Lima can manage daemons for networks defined in $LIMA_HOME/_config/networks.yaml
320320
# automatically. The socket_vmnet binary must be installed into
321321
# secure locations only alterable by the "root" user.
322-
# The same applies to vde_switch and vde_vmnet for the deprecated VDE mode.
323322
# - lima: shared
324323
# # MAC address of the instance; lima will pick one based on the instance name,
325324
# # so DHCP assigned ip addresses should remain constant over instance restarts.
@@ -338,19 +337,6 @@ networks:
338337
# Needs `vmType: vz` (EXPERIMENTAL).
339338
# - vzNAT: true
340339

341-
# vnl (virtual network locator) points to the vde_switch socket directory,
342-
# optionally with vde:// prefix
343-
# ⚠️ vnl is deprecated, use socket.
344-
# - vnl: "vde:///var/run/vde.ctl"
345-
# # VDE Switch port number (not TCP/UDP port number). Set to 65535 for PTP mode.
346-
# # Builtin default: 0
347-
# switchPort: 0
348-
# # MAC address of the instance; lima will pick one based on the instance name,
349-
# # so DHCP assigned ip addresses should remain constant over instance restarts.
350-
# macAddress: ""
351-
# # Interface name, defaults to "lima0", "lima1", etc.
352-
# interface: ""
353-
354340
# Port forwarding rules. Forwarding between ports 22 and ssh.localPort cannot be overridden.
355341
# Rules are checked sequentially until the first one matches.
356342
# portForwards:

examples/vmnet.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ mounts:
2828
writable: true
2929
networks:
3030
# The instance can get routable IP addresses from the vmnet framework using
31-
# https://github.com/lima-vm/socket_vmnet (since Lima v0.12) or
32-
# https://github.com/lima-vm/vde_vmnet (deprecated) .
31+
# https://github.com/lima-vm/socket_vmnet (since Lima v0.12).
3332
#
3433
# Available networks are defined in
3534
# $LIMA_HOME/_config/networks.yaml. Supported network types are "host",

pkg/limayaml/defaults.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -508,38 +508,18 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
508508
iface := make(map[string]int)
509509
for _, nw := range append(append(d.Networks, y.Networks...), o.Networks...) {
510510
if i, ok := iface[nw.Interface]; ok {
511-
if nw.VNLDeprecated != "" {
512-
networks[i].VNLDeprecated = nw.VNLDeprecated
513-
networks[i].SwitchPortDeprecated = nw.SwitchPortDeprecated
514-
networks[i].Socket = ""
515-
networks[i].Lima = ""
516-
}
517511
if nw.Socket != "" {
518-
if nw.VNLDeprecated != "" {
519-
// We can't return an error, so just log it, and prefer `socket` over `vnl`
520-
logrus.Errorf("Network %q has both vnl=%q and socket=%q fields; ignoring vnl",
521-
nw.Interface, nw.VNLDeprecated, nw.Socket)
522-
}
523512
networks[i].Socket = nw.Socket
524-
networks[i].VNLDeprecated = ""
525-
networks[i].SwitchPortDeprecated = 0
526513
networks[i].Lima = ""
527514
}
528515
if nw.Lima != "" {
529-
if nw.VNLDeprecated != "" {
530-
// We can't return an error, so just log it, and prefer `lima` over `vnl`
531-
logrus.Errorf("Network %q has both vnl=%q and lima=%q fields; ignoring vnl",
532-
nw.Interface, nw.VNLDeprecated, nw.Lima)
533-
}
534516
if nw.Socket != "" {
535517
// We can't return an error, so just log it, and prefer `lima` over `socket`
536518
logrus.Errorf("Network %q has both socket=%q and lima=%q fields; ignoring socket",
537519
nw.Interface, nw.Socket, nw.Lima)
538520
}
539521
networks[i].Lima = nw.Lima
540522
networks[i].Socket = ""
541-
networks[i].VNLDeprecated = ""
542-
networks[i].SwitchPortDeprecated = 0
543523
}
544524
if nw.MACAddress != "" {
545525
networks[i].MACAddress = nw.MACAddress

pkg/limayaml/defaults_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,8 @@ func TestFillDefault(t *testing.T) {
377377
},
378378
Networks: []Network{
379379
{
380-
VNLDeprecated: "/tmp/vde.ctl",
381-
SwitchPortDeprecated: 65535,
382-
MACAddress: "11:22:33:44:55:66",
383-
Interface: "def0",
380+
MACAddress: "11:22:33:44:55:66",
381+
Interface: "def0",
384382
},
385383
},
386384
DNS: []net.IP{
@@ -645,8 +643,6 @@ func TestFillDefault(t *testing.T) {
645643
// o.Networks[1] is overriding the d.Networks[0].Lima entry for the "def0" interface
646644
expect.Networks = append(append(d.Networks, y.Networks...), o.Networks[0])
647645
expect.Networks[0].Lima = o.Networks[1].Lima
648-
expect.Networks[0].VNLDeprecated = ""
649-
expect.Networks[0].SwitchPortDeprecated = 0
650646

651647
// Only highest prio DNS are retained
652648
expect.DNS = o.DNS

pkg/limayaml/limayaml.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,15 @@ type CopyToHost struct {
233233
}
234234

235235
type Network struct {
236-
// `Lima`, `Socket`, and `VNL` are mutually exclusive; exactly one is required
236+
// `Lima` and `Socket` are mutually exclusive; exactly one is required
237237
Lima string `yaml:"lima,omitempty" json:"lima,omitempty"`
238238
// Socket is a QEMU-compatible socket
239239
Socket string `yaml:"socket,omitempty" json:"socket,omitempty"`
240240
// VZNAT uses VZNATNetworkDeviceAttachment. Needs VZ. No root privilege is required.
241241
VZNAT *bool `yaml:"vzNAT,omitempty" json:"vzNAT,omitempty"`
242242

243-
// VNLDeprecated is a Virtual Network Locator (https://github.com/rd235/vdeplug4/commit/089984200f447abb0e825eb45548b781ba1ebccd).
244-
// On macOS, only VDE2-compatible form (optionally with vde:// prefix) is supported.
245-
// VNLDeprecated is deprecated. Use Socket.
246-
VNLDeprecated string `yaml:"vnl,omitempty" json:"vnl,omitempty"`
247-
SwitchPortDeprecated uint16 `yaml:"switchPort,omitempty" json:"switchPort,omitempty"` // VDE Switch port, not TCP/UDP port (only used by VDE networking)
248-
MACAddress string `yaml:"macAddress,omitempty" json:"macAddress,omitempty"`
249-
Interface string `yaml:"interface,omitempty" json:"interface,omitempty"`
243+
MACAddress string `yaml:"macAddress,omitempty" json:"macAddress,omitempty"`
244+
Interface string `yaml:"interface,omitempty" json:"interface,omitempty"`
250245
}
251246

252247
type HostResolver struct {
@@ -260,15 +255,3 @@ type CACertificates struct {
260255
Files []string `yaml:"files,omitempty" json:"files,omitempty"`
261256
Certs []string `yaml:"certs,omitempty" json:"certs,omitempty"`
262257
}
263-
264-
// DEPRECATED types below
265-
266-
// Types have been renamed to turn all references to the old names into compiler errors,
267-
// and to avoid accidental usage in new code.
268-
269-
type VDEDeprecated struct {
270-
VNL string `yaml:"vnl,omitempty" json:"vnl,omitempty"`
271-
SwitchPort uint16 `yaml:"switchPort,omitempty" json:"switchPort,omitempty"` // VDE Switch port, not TCP/UDP port
272-
MACAddress string `yaml:"macAddress,omitempty" json:"macAddress,omitempty"`
273-
Name string `yaml:"name,omitempty" json:"name,omitempty"`
274-
}

pkg/limayaml/validate.go

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func Validate(y LimaYAML, warn bool) error {
300300
return fmt.Errorf("field `dns` must be empty when field `HostResolver.Enabled` is true")
301301
}
302302

303-
if err := validateNetwork(y, warn); err != nil {
303+
if err := validateNetwork(y); err != nil {
304304
return err
305305
}
306306
if warn {
@@ -309,7 +309,7 @@ func Validate(y LimaYAML, warn bool) error {
309309
return nil
310310
}
311311

312-
func validateNetwork(y LimaYAML, warn bool) error {
312+
func validateNetwork(y LimaYAML) error {
313313
interfaceName := make(map[string]int)
314314
for i, nw := range y.Networks {
315315
field := fmt.Sprintf("networks[%d]", i)
@@ -334,22 +334,10 @@ func validateNetwork(y LimaYAML, warn bool) error {
334334
if nw.VZNAT != nil && *nw.VZNAT {
335335
return fmt.Errorf("field `%s.lima` and field `%s.vzNAT` are mutually exclusive", field, field)
336336
}
337-
if nw.VNLDeprecated != "" {
338-
return fmt.Errorf("field `%s.lima` and field `%s.vnl` are mutually exclusive", field, field)
339-
}
340-
if nw.SwitchPortDeprecated != 0 {
341-
return fmt.Errorf("field `%s.switchPort` cannot be used with field `%s.lima`", field, field)
342-
}
343337
} else if nw.Socket != "" {
344338
if nw.VZNAT != nil && *nw.VZNAT {
345339
return fmt.Errorf("field `%s.socket` and field `%s.vzNAT` are mutually exclusive", field, field)
346340
}
347-
if nw.VNLDeprecated != "" {
348-
return fmt.Errorf("field `%s.socket` and field `%s.vnl` are mutually exclusive", field, field)
349-
}
350-
if nw.SwitchPortDeprecated != 0 {
351-
return fmt.Errorf("field `%s.switchPort` cannot be used with field `%s.socket`", field, field)
352-
}
353341
if fi, err := os.Stat(nw.Socket); err != nil && !errors.Is(err, os.ErrNotExist) {
354342
return err
355343
} else if err == nil && fi.Mode()&os.ModeSocket == 0 {
@@ -365,54 +353,8 @@ func validateNetwork(y LimaYAML, warn bool) error {
365353
if nw.Socket != "" {
366354
return fmt.Errorf("field `%s.vzNAT` and field `%s.socket` are mutually exclusive", field, field)
367355
}
368-
if nw.VNLDeprecated != "" {
369-
return fmt.Errorf("field `%s.vzNAT` and field `%s.vnl` are mutually exclusive", field, field)
370-
}
371-
if nw.SwitchPortDeprecated != 0 {
372-
return fmt.Errorf("field `%s.switchPort` cannot be used with field `%s.vzNAT`", field, field)
373-
}
374356
} else {
375-
if nw.VNLDeprecated == "" {
376-
return fmt.Errorf("field `%s.lima`, field `%s.socket`, or field `%s.vnl` must be set", field, field, field)
377-
}
378-
// The field is called VDE.VNL in anticipation of QEMU upgrading VDE2 to VDEplug4,
379-
// but right now the only valid value on macOS is a path to the vde_switch socket directory,
380-
// optionally with vde:// prefix.
381-
if !strings.Contains(nw.VNLDeprecated, "://") || strings.HasPrefix(nw.VNLDeprecated, "vde://") {
382-
vdeSwitch := strings.TrimPrefix(nw.VNLDeprecated, "vde://")
383-
if fi, err := os.Stat(vdeSwitch); err != nil {
384-
// negligible when the instance is stopped
385-
logrus.WithError(err).Debugf("field `%s.vnl` %q failed stat", field, vdeSwitch)
386-
} else {
387-
if fi.IsDir() {
388-
/* Switch mode (vdeSwitch is dir, port != 65535) */
389-
ctlSocket := filepath.Join(vdeSwitch, "ctl")
390-
// ErrNotExist during os.Stat(ctlSocket) can be ignored. ctlSocket does not need to exist until actually starting the VM
391-
if fi, err = os.Stat(ctlSocket); err == nil {
392-
if fi.Mode()&os.ModeSocket == 0 {
393-
return fmt.Errorf("field `%s.vnl` file %q is not a UNIX socket", field, ctlSocket)
394-
}
395-
}
396-
if nw.SwitchPortDeprecated == 65535 {
397-
return fmt.Errorf("field `%s.vnl` points to a non-PTP switch, so the port number must not be 65535", field)
398-
}
399-
} else {
400-
/* PTP mode (vdeSwitch is socket, port == 65535) */
401-
if fi.Mode()&os.ModeSocket == 0 {
402-
return fmt.Errorf("field `%s.vnl` %q is not a directory nor a UNIX socket", field, vdeSwitch)
403-
}
404-
if nw.SwitchPortDeprecated != 65535 {
405-
return fmt.Errorf("field `%s.vnl` points to a PTP (switchless) socket %q, so the port number has to be 65535 (got %d)",
406-
field, vdeSwitch, nw.SwitchPortDeprecated)
407-
}
408-
}
409-
}
410-
} else if runtime.GOOS != "linux" {
411-
if warn {
412-
logrus.Warnf("field `%s.vnl` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)",
413-
field, runtime.GOOS, runtime.GOOS)
414-
}
415-
}
357+
return fmt.Errorf("field `%s.lima` or field `%s.socket must be set", field, field)
416358
}
417359
if nw.MACAddress != "" {
418360
hw, err := net.ParseMAC(nw.MACAddress)

pkg/networks/commands.go

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import (
66
"io/fs"
77
"os/exec"
88
"path/filepath"
9-
"strings"
109

1110
"github.com/lima-vm/lima/pkg/osutil"
1211
"github.com/lima-vm/lima/pkg/store/dirnames"
1312
)
1413

1514
const (
16-
VDESwitch = "vde_switch" // Deprecated
17-
VDEVMNet = "vde_vmnet" // Deprecated
1815
SocketVMNet = "socket_vmnet"
1916
)
2017

@@ -39,10 +36,6 @@ func (config *YAML) Usernet(name string) (bool, error) {
3936
// DaemonPath returns the daemon path.
4037
func (config *YAML) DaemonPath(daemon string) (string, error) {
4138
switch daemon {
42-
case VDESwitch:
43-
return config.Paths.VDESwitch, nil
44-
case VDEVMNet:
45-
return config.Paths.VDEVMNet, nil
4639
case SocketVMNet:
4740
return config.Paths.SocketVMNet, nil
4841
default:
@@ -73,40 +66,23 @@ func (config *YAML) Sock(name string) string {
7366
return filepath.Join(config.Paths.VarRun, fmt.Sprintf("socket_vmnet.%s", name))
7467
}
7568

76-
// VDESock returns a vde socket.
77-
//
78-
// Deprecated: Use Sock.
79-
func (config *YAML) VDESock(name string) string {
80-
return filepath.Join(config.Paths.VarRun, fmt.Sprintf("%s.ctl", name))
81-
}
82-
8369
func (config *YAML) PIDFile(name, daemon string) string {
84-
daemonTrimmed := strings.TrimPrefix(daemon, "vde_") // for compatibility
85-
return filepath.Join(config.Paths.VarRun, fmt.Sprintf("%s_%s.pid", name, daemonTrimmed))
70+
return filepath.Join(config.Paths.VarRun, fmt.Sprintf("%s_%s.pid", name, daemon))
8671
}
8772

8873
func (config *YAML) LogFile(name, daemon, stream string) string {
8974
networksDir, _ := dirnames.LimaNetworksDir()
90-
daemonTrimmed := strings.TrimPrefix(daemon, "vde_") // for compatibility
91-
return filepath.Join(networksDir, fmt.Sprintf("%s_%s.%s.log", name, daemonTrimmed, stream))
75+
return filepath.Join(networksDir, fmt.Sprintf("%s_%s.%s.log", name, daemon, stream))
9276
}
9377

9478
func (config *YAML) User(daemon string) (osutil.User, error) {
9579
if ok, _ := config.IsDaemonInstalled(daemon); !ok {
9680
daemonPath, _ := config.DaemonPath(daemon)
9781
return osutil.User{}, fmt.Errorf("daemon %q (path=%q) is not available", daemon, daemonPath)
9882
}
83+
//nolint:gocritic // singleCaseSwitch: should rewrite switch statement to if statement
9984
switch daemon {
100-
case VDESwitch:
101-
user, err := osutil.LookupUser("daemon")
102-
if err != nil {
103-
return user, err
104-
}
105-
group, err := osutil.LookupGroup(config.Group)
106-
user.Group = group.Name
107-
user.Gid = group.Gid
108-
return user, err
109-
case VDEVMNet, SocketVMNet:
85+
case SocketVMNet:
11086
return osutil.LookupUser("root")
11187
}
11288
return osutil.User{}, fmt.Errorf("daemon %q not defined", daemon)
@@ -122,27 +98,6 @@ func (config *YAML) StartCmd(name, daemon string) string {
12298
}
12399
var cmd string
124100
switch daemon {
125-
case VDESwitch:
126-
if config.Paths.VDESwitch == "" {
127-
panic("config.Paths.VDESwitch is empty")
128-
}
129-
cmd = fmt.Sprintf("%s --pidfile=%s --sock=%s --group=%s --dirmode=0770 --nostdin",
130-
config.Paths.VDESwitch, config.PIDFile(name, VDESwitch), config.VDESock(name), config.Group)
131-
case VDEVMNet:
132-
nw := config.Networks[name]
133-
if config.Paths.VDEVMNet == "" {
134-
panic("config.Paths.VDEVMNet is empty")
135-
}
136-
cmd = fmt.Sprintf("%s --pidfile=%s --vde-group=%s --vmnet-mode=%s",
137-
config.Paths.VDEVMNet, config.PIDFile(name, VDEVMNet), config.Group, nw.Mode)
138-
switch nw.Mode {
139-
case ModeBridged:
140-
cmd += fmt.Sprintf(" --vmnet-interface=%s", nw.Interface)
141-
case ModeHost, ModeShared:
142-
cmd += fmt.Sprintf(" --vmnet-gateway=%s --vmnet-dhcp-end=%s --vmnet-mask=%s",
143-
nw.Gateway, nw.DHCPEnd, nw.NetMask)
144-
}
145-
cmd += " " + config.VDESock(name)
146101
case SocketVMNet:
147102
nw := config.Networks[name]
148103
if config.Paths.SocketVMNet == "" {
@@ -158,6 +113,8 @@ func (config *YAML) StartCmd(name, daemon string) string {
158113
nw.Gateway, nw.DHCPEnd, nw.NetMask)
159114
}
160115
cmd += " " + config.Sock(name)
116+
default:
117+
panic(fmt.Errorf("unexpected daemon %q", daemon))
161118
}
162119
return cmd
163120
}

pkg/networks/commands_darwin_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ func TestSock(t *testing.T) {
1414
assert.Equal(t, sock, "/private/var/run/lima/socket_vmnet.foo")
1515
}
1616

17-
func TestVDESock(t *testing.T) {
18-
config, err := DefaultConfig()
19-
assert.NilError(t, err)
20-
21-
vdeSock := config.VDESock("foo")
22-
assert.Equal(t, vdeSock, "/private/var/run/lima/foo.ctl")
23-
}
24-
2517
func TestPIDFile(t *testing.T) {
2618
config, err := DefaultConfig()
2719
assert.NilError(t, err)

0 commit comments

Comments
 (0)