Skip to content

Commit 9d0ad92

Browse files
committed
incus: always use vmnet for network address
Signed-off-by: Abiola Ibrahim <[email protected]>
1 parent 67330d0 commit 9d0ad92

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

environment/container/incus/incus.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ func (c incusRuntime) registerNetworks() error {
263263
return fmt.Errorf("error creating managed network '%s': %w", name, err)
264264
}
265265

266-
// set as default network
267-
err = c.guest.RunQuiet("sudo", "incus", "profile", "device", "set", "default", "eth0", "network="+name)
268-
if err != nil {
269-
return fmt.Errorf("error setting managed network '%s' as default: %w", name, err)
270-
}
271-
272266
return nil
273267
}
274268

environment/vm/lima/daemon.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ import (
99
"github.com/abiosoft/colima/daemon"
1010
"github.com/abiosoft/colima/daemon/process/inotify"
1111
"github.com/abiosoft/colima/daemon/process/vmnet"
12+
"github.com/abiosoft/colima/environment/container/incus"
1213
"github.com/abiosoft/colima/environment/vm/lima/limaconfig"
1314
"github.com/abiosoft/colima/util"
1415
)
1516

1617
func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.Context, error) {
17-
isQEMU := conf.VMType == limaconfig.QEMU
18-
isVZ := conf.VMType == limaconfig.VZ
18+
// vmnet is used by QEMU and always used by incus (even with VZ)
19+
useVmnet := conf.VMType == limaconfig.QEMU || conf.Runtime == incus.Name
1920

20-
// network daemon is only needed for qemu
21-
conf.Network.Address = conf.Network.Address && isQEMU
21+
// network daemon is only needed for vmnet
22+
conf.Network.Address = conf.Network.Address && useVmnet
2223

23-
// limited to macOS (with Qemu driver)
24-
// or vz with inotify enabled
25-
if !util.MacOS() || (isVZ && !conf.MountINotify) {
24+
// limited to macOS (with vmnet required)
25+
// or with inotify enabled
26+
if !util.MacOS() || (!conf.MountINotify && !conf.Network.Address) {
2627
return ctx, nil
2728
}
2829

@@ -48,7 +49,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C
4849
}
4950

5051
// add network processes to daemon
51-
if isQEMU {
52+
if useVmnet {
5253
a.Add(func() error {
5354
if conf.Network.Address {
5455
a.Stage("preparing network")
@@ -104,7 +105,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C
104105

105106
// network failure is not fatal
106107
if err := a.Exec(); err != nil {
107-
if isQEMU {
108+
if useVmnet {
108109
func() {
109110
installed, _ := ctx.Value(networkInstalledKey).(bool)
110111
if !installed {

environment/vm/lima/yaml.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err
130130

131131
reachableIPAddress := true
132132
if conf.Network.Address {
133-
if l.VMType == limaconfig.VZ {
133+
// incus always uses vmnet
134+
if l.VMType == limaconfig.VZ && conf.Runtime != incus.Name {
134135
l.Networks = append(l.Networks, limaconfig.Network{
135136
VZNAT: true,
136137
Interface: limautil.NetInterface,

0 commit comments

Comments
 (0)