Skip to content

Commit

Permalink
incus: always use vmnet for network address
Browse files Browse the repository at this point in the history
Signed-off-by: Abiola Ibrahim <[email protected]>
  • Loading branch information
abiosoft committed Aug 26, 2024
1 parent 67330d0 commit 9d0ad92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
6 changes: 0 additions & 6 deletions environment/container/incus/incus.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ func (c incusRuntime) registerNetworks() error {
return fmt.Errorf("error creating managed network '%s': %w", name, err)
}

// set as default network
err = c.guest.RunQuiet("sudo", "incus", "profile", "device", "set", "default", "eth0", "network="+name)
if err != nil {
return fmt.Errorf("error setting managed network '%s' as default: %w", name, err)
}

return nil
}

Expand Down
19 changes: 10 additions & 9 deletions environment/vm/lima/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ import (
"github.com/abiosoft/colima/daemon"
"github.com/abiosoft/colima/daemon/process/inotify"
"github.com/abiosoft/colima/daemon/process/vmnet"
"github.com/abiosoft/colima/environment/container/incus"
"github.com/abiosoft/colima/environment/vm/lima/limaconfig"
"github.com/abiosoft/colima/util"
)

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

// network daemon is only needed for qemu
conf.Network.Address = conf.Network.Address && isQEMU
// network daemon is only needed for vmnet
conf.Network.Address = conf.Network.Address && useVmnet

// limited to macOS (with Qemu driver)
// or vz with inotify enabled
if !util.MacOS() || (isVZ && !conf.MountINotify) {
// limited to macOS (with vmnet required)
// or with inotify enabled
if !util.MacOS() || (!conf.MountINotify && !conf.Network.Address) {
return ctx, nil
}

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

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

// network failure is not fatal
if err := a.Exec(); err != nil {
if isQEMU {
if useVmnet {
func() {
installed, _ := ctx.Value(networkInstalledKey).(bool)
if !installed {
Expand Down
3 changes: 2 additions & 1 deletion environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err

reachableIPAddress := true
if conf.Network.Address {
if l.VMType == limaconfig.VZ {
// incus always uses vmnet
if l.VMType == limaconfig.VZ && conf.Runtime != incus.Name {
l.Networks = append(l.Networks, limaconfig.Network{
VZNAT: true,
Interface: limautil.NetInterface,
Expand Down

0 comments on commit 9d0ad92

Please sign in to comment.