Skip to content

Commit 14c7ed0

Browse files
committed
add user-mode networking option on hyperv
Signed-off-by: lstocchi <[email protected]>
1 parent 9403648 commit 14c7ed0

File tree

10 files changed

+246
-61
lines changed

10 files changed

+246
-61
lines changed

cmd/macadam/init.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var (
3232
ValidArgsFunction: completion.AutocompleteNone,
3333
}
3434

35-
initOptsFromFlags = define.InitOptions{}
36-
// initOptionalFlags = InitOptionalFlags{}
35+
initOptsFromFlags = define.InitOptions{}
36+
initOptionalFlags = InitOptionalFlags{}
3737
defaultMachineName = "macadam"
3838
// now bool
3939
)
@@ -78,6 +78,10 @@ func init() {
7878
flags.Uint64VarP(&initOptsFromFlags.Memory, memoryFlagName, "m", 4096, "Memory in MiB")
7979
_ = initCmd.RegisterFlagCompletionFunc(memoryFlagName, completion.AutocompleteNone)
8080

81+
userModeNetFlagName := "user-mode-networking"
82+
flags.BoolVar(&initOptionalFlags.UserModeNetworking, userModeNetFlagName, false,
83+
"Whether this machine should use user-mode networking, routing traffic through a host user-space process")
84+
8185
/* flags := initCmd.Flags()
8286
cfg := registry.PodmanConfig()
8387
@@ -138,11 +142,7 @@ func init() {
138142
_ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault)
139143
140144
rootfulFlagName := "rootful"
141-
flags.BoolVar(&initOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution")
142-
143-
userModeNetFlagName := "user-mode-networking"
144-
flags.BoolVar(&initOptionalFlags.UserModeNetworking, userModeNetFlagName, false,
145-
"Whether this machine should use user-mode networking, routing traffic through a host user-space process") */
145+
flags.BoolVar(&initOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution") */
146146
}
147147

148148
func initMachine(cmd *cobra.Command, args []string) error {
@@ -151,7 +151,7 @@ func initMachine(cmd *cobra.Command, args []string) error {
151151
return err
152152
}
153153

154-
if err := preflights.RunPreflights(vmProvider); err != nil {
154+
if err := preflights.RunPreflights(vmProvider, initOptionalFlags.UserModeNetworking); err != nil {
155155
slog.Error(err.Error())
156156
os.Exit(1)
157157
}
@@ -210,6 +210,7 @@ func initMachine(cmd *cobra.Command, args []string) error {
210210
HasReadyUnit: false,
211211
ForwardSockets: false,
212212
}
213+
initOpts.UserModeNetworking = &initOptionalFlags.UserModeNetworking
213214
/*
214215
_, _, err = shim.VMExists(machineName, []vmconfigs.VMProvider{provider})
215216
if err == nil {

cmd/macadam/preflight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ func preflight(_ *cobra.Command, args []string) error {
2929
if err != nil {
3030
return err
3131
}
32-
return preflights.RunPreflights(vmProvider)
32+
return preflights.RunPreflights(vmProvider, false)
3333
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,6 @@ require (
190190
tags.cncf.io/container-device-interface/specs-go v1.0.0 // indirect
191191
)
192192

193-
replace github.com/containers/podman/v5 => github.com/cfergeau/podman/v5 v5.0.0-20250827094930-c4e064e63225
193+
replace github.com/containers/podman/v5 => github.com/lstocchi/podman/v5 v5.0.0-20250829132130-204feaa03b25
194194

195195
replace github.com/crc-org/machine => github.com/cfergeau/machine v0.0.0-20241127155529-1b8b9b8d1078

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
3333
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
3434
github.com/cfergeau/machine v0.0.0-20241127155529-1b8b9b8d1078 h1:KpgRncgq6ZiWDnLe6R58dJjd6QSuU7RDqRrpl11Dxcg=
3535
github.com/cfergeau/machine v0.0.0-20241127155529-1b8b9b8d1078/go.mod h1:trWeQimjfE3dJ8qWOxI4ePtYm13aecK42bf01s6h/Nc=
36-
github.com/cfergeau/podman/v5 v5.0.0-20250827094930-c4e064e63225 h1:6mU03Tns0Xxi+E0pp8E7VC3QaaDLNloZWF+URuALRg0=
37-
github.com/cfergeau/podman/v5 v5.0.0-20250827094930-c4e064e63225/go.mod h1:AkMebnGmyIu6vXJnzObFM7huGUfkdQhQ+vqRw7Qo9l4=
3836
github.com/checkpoint-restore/checkpointctl v1.3.0 h1:bNz5b6s+lxFdG5ZGDba3qSkBtXDDTCG2494dfAbQJ4E=
3937
github.com/checkpoint-restore/checkpointctl v1.3.0/go.mod h1:dqZH4wDvbjnsqFGK2LdUDk21yFQ1dCAtzgRMlG44KDM=
4038
github.com/checkpoint-restore/go-criu/v7 v7.2.0 h1:qGiWA4App1gGlEfIJ68WR9jbezV9J7yZdjzglezcqKo=
@@ -244,6 +242,8 @@ github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec h1:2tTW6cDth2T
244242
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec/go.mod h1:TmwEoGCwIti7BCeJ9hescZgRtatxRE+A72pCoPfmcfk=
245243
github.com/lima-vm/go-qcow2reader v0.6.0 h1:dNstUGQxEUPbmiiVnu/cek2x7scrHe2VJy5JseLLflo=
246244
github.com/lima-vm/go-qcow2reader v0.6.0/go.mod h1:ay45SlGOzU+2Vc21g5/lmQgPn7Hmf0JpPhm8cuOK1FI=
245+
github.com/lstocchi/podman/v5 v5.0.0-20250829132130-204feaa03b25 h1:cHflj+1lfo6OYuAPWVTbvndMtDAxJdQpcR6360ltHT0=
246+
github.com/lstocchi/podman/v5 v5.0.0-20250829132130-204feaa03b25/go.mod h1:AkMebnGmyIu6vXJnzObFM7huGUfkdQhQ+vqRw7Qo9l4=
247247
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
248248
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
249249
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=

pkg/preflights/preflights.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
1313
)
1414

15-
func RunPreflights(provider vmconfigs.VMProvider) error {
16-
if err := checkGvproxyVersion(provider); err != nil {
15+
func RunPreflights(provider vmconfigs.VMProvider, userModeNetworking bool) error {
16+
if err := checkGvproxyVersion(provider, userModeNetworking); err != nil {
1717
return fmt.Errorf("invalid gvproxy binary: %w", err)
1818
}
1919

@@ -30,8 +30,8 @@ func RunPreflights(provider vmconfigs.VMProvider) error {
3030

3131
// macadam/podman needs a gvproxy version which supports the --services
3232
// argument
33-
func checkGvproxyVersion(provider vmconfigs.VMProvider) error {
34-
if provider.VMType() == define.WSLVirt || provider.VMType() == define.HyperVVirt {
33+
func checkGvproxyVersion(provider vmconfigs.VMProvider, userModeNetworking bool) error {
34+
if provider.VMType() == define.WSLVirt || (provider.VMType() == define.HyperVVirt && !userModeNetworking) {
3535
return nil
3636
}
3737
if err := checkBinaryArg(machine.ForwarderBinaryName, "-services"); err != nil {

vendor/github.com/containers/podman/v5/pkg/machine/cloudinit/cloudinit.go

Lines changed: 10 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/podman/v5/pkg/machine/cloudinit/cloudinit_rest.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containers/podman/v5/pkg/machine/cloudinit/cloudinit_windows.go

Lines changed: 165 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)