Skip to content

Commit 5e19bb8

Browse files
committed
vde: change "url" to "vnl" (Virtual Network Locator)
To follow the latest VDE nomenclature. rd235/vdeplug4@0899842 Signed-off-by: Akihiro Suda <[email protected]>
1 parent de30a2e commit 5e19bb8

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

docs/network.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ network:
3434
# daemons must be running before the instance is started. The interface type
3535
# (host, shared, or bridged) is configured in vde_vmnet and not lima.
3636
vde:
37-
# url points to the vde_switch socket directory, optionally with vde:// prefix
38-
- url: "vde:///var/run/vde.ctl"
37+
# vnl (virtual network locator) points to the vde_switch socket directory,
38+
# optionally with vde:// prefix
39+
- vnl: "vde:///var/run/vde.ctl"
3940
# MAC address of the instance; lima will pick one based on the instance name,
4041
# so DHCP assigned ip addresses should remain constant over instance restarts.
4142
macAddress: ""

examples/vmnet.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ network:
2020
# daemons must be running before the instance is started. The interface type
2121
# (host, shared, or bridged) is configured in vde_vmnet and not lima.
2222
vde:
23-
- url: "vde:///var/run/vde.ctl"
23+
- vnl: "vde:///var/run/vde.ctl"

pkg/limayaml/default.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ network:
125125
# daemons must be running before the instance is started. The interface type
126126
# (host, shared, or bridged) is configured in vde_vmnet and not lima.
127127
vde:
128-
# url points to the vde_switch socket directory, optionally with vde:// prefix
129-
# - url: "vde:///var/run/vde.ctl"
128+
# vnl (virtual network locator) points to the vde_switch socket directory,
129+
# optionally with vde:// prefix
130+
# - vnl: "vde:///var/run/vde.ctl"
130131
# # VDE Switch port number (not TCP/UDP port number). Set to 65535 for PTP mode.
131132
# # Default: 0
132133
# switchPort: 0

pkg/limayaml/limayaml.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ type Network struct {
111111
VDE []VDE `yaml:"vde,omitempty"`
112112
}
113113
type VDE struct {
114-
URL string `yaml:"url,omitempty"`
114+
// VNL is a Virtual Network Locator (https://github.com/rd235/vdeplug4/commit/089984200f447abb0e825eb45548b781ba1ebccd).
115+
// On macOS, only VDE2-compatible form (optionally with vde:// prefix) is supported.
116+
VNL string `yaml:"vnl,omitempty"`
115117
SwitchPort uint16 `yaml:"switchPort,omitempty"` // VDE Switch port, not TCP/UDP port
116118
MACAddress string `yaml:"macAddress,omitempty"`
117119
Name string `yaml:"name,omitempty"`

pkg/limayaml/validate.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -174,43 +174,43 @@ func validateNetwork(yNetwork Network) error {
174174
networkName := make(map[string]int)
175175
for i, vde := range yNetwork.VDE {
176176
field := fmt.Sprintf("network.vde[%d]", i)
177-
if vde.URL == "" {
178-
return errors.Errorf("field `%s.url` must not be empty", field)
177+
if vde.VNL == "" {
178+
return errors.Errorf("field `%s.vnl` must not be empty", field)
179179
}
180-
// The field is called VDE.URL in anticipation of QEMU upgrading VDE2 to VDEplug4,
180+
// The field is called VDE.VNL in anticipation of QEMU upgrading VDE2 to VDEplug4,
181181
// but right now the only valid value on macOS is a path to the vde_switch socket directory,
182182
// optionally with vde:// prefix.
183-
if !strings.Contains(vde.URL, "://") || strings.HasPrefix(vde.URL, "vde://") {
184-
vdeSwitch := strings.TrimPrefix(vde.URL, "vde://")
183+
if !strings.Contains(vde.VNL, "://") || strings.HasPrefix(vde.VNL, "vde://") {
184+
vdeSwitch := strings.TrimPrefix(vde.VNL, "vde://")
185185
fi, err := os.Stat(vdeSwitch)
186186
if err != nil {
187-
return errors.Wrapf(err, "field `%s.url` %q failed stat", field, vdeSwitch)
187+
return errors.Wrapf(err, "field `%s.vnl` %q failed stat", field, vdeSwitch)
188188
}
189189
if fi.IsDir() {
190190
/* Switch mode (vdeSwitch is dir, port != 65535) */
191191
ctlSocket := filepath.Join(vdeSwitch, "ctl")
192192
fi, err = os.Stat(ctlSocket)
193193
if err != nil {
194-
return errors.Wrapf(err, "field `%s.url` control socket %q failed stat", field, ctlSocket)
194+
return errors.Wrapf(err, "field `%s.vnl` control socket %q failed stat", field, ctlSocket)
195195
}
196196
if fi.Mode()&os.ModeSocket == 0 {
197-
return errors.Errorf("field `%s.url` file %q is not a UNIX socket", field, ctlSocket)
197+
return errors.Errorf("field `%s.vnl` file %q is not a UNIX socket", field, ctlSocket)
198198
}
199199
if vde.SwitchPort == 65535 {
200-
return errors.Errorf("field `%s.url` points to a non-PTP switch, so the port number must not be 65535", field)
200+
return errors.Errorf("field `%s.vnl` points to a non-PTP switch, so the port number must not be 65535", field)
201201
}
202202
} else {
203203
/* PTP mode (vdeSwitch is socket, port == 65535) */
204204
if fi.Mode()&os.ModeSocket == 0 {
205-
return errors.Errorf("field `%s.url` %q is not a directory nor a UNIX socket", field, vdeSwitch)
205+
return errors.Errorf("field `%s.vnl` %q is not a directory nor a UNIX socket", field, vdeSwitch)
206206
}
207207
if vde.SwitchPort != 65535 {
208-
return errors.Errorf("field `%s.url` points to a PTP (switchless) socket %q, so the port number has to be 65535 (got %d)",
208+
return errors.Errorf("field `%s.vnl` points to a PTP (switchless) socket %q, so the port number has to be 65535 (got %d)",
209209
field, vdeSwitch, vde.SwitchPort)
210210
}
211211
}
212212
} else if runtime.GOOS != "linux" {
213-
logrus.Warnf("field `%s.url` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)",
213+
logrus.Warnf("field `%s.vnl` is unlikely to work for %s (unless libvdeplug4 has been ported to %s and is installed)",
214214
field, runtime.GOOS, runtime.GOOS)
215215
}
216216
if vde.MACAddress != "" {

pkg/qemu/qemu.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ func Cmdline(cfg Config) (string, []string, error) {
197197
args = append(args, "-netdev", fmt.Sprintf("user,id=net0,net=192.168.5.0/24,hostfwd=tcp:127.0.0.1:%d-:22", y.SSH.LocalPort))
198198
args = append(args, "-device", "virtio-net-pci,netdev=net0,mac="+limayaml.MACAddress(cfg.InstanceDir))
199199
for i, vde := range y.Network.VDE {
200-
// VDE4 accepts URL such as vde:///var/run/vde.ctl as well as file path such as /var/run/vde.ctl .
200+
// VDE4 accepts VNL like vde:///var/run/vde.ctl as well as file path like /var/run/vde.ctl .
201201
// VDE2 only accepts the latter form.
202202
// VDE2 supports macOS but VDE4 does not yet, so we trim vde:// prefix here for VDE2 compatibility.
203-
vdeSock := strings.TrimPrefix(vde.URL, "vde://")
203+
vdeSock := strings.TrimPrefix(vde.VNL, "vde://")
204204
args = append(args, "-netdev", fmt.Sprintf("vde,id=net%d,sock=%s", i+1, vdeSock))
205205
args = append(args, "-device", fmt.Sprintf("virtio-net-pci,netdev=net%d,mac=%s", i+1, vde.MACAddress))
206206
}

0 commit comments

Comments
 (0)