Skip to content

Commit

Permalink
Merge pull request containers#20804 from BlackHole1/improve-vmtype
Browse files Browse the repository at this point in the history
refactor(machine): improve machine marker value
  • Loading branch information
openshift-merge-bot[bot] committed Nov 28, 2023
2 parents 83c08a2 + a2bf8c6 commit 443e779
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/rootlessport/wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func splitDualStackSpecIfWsl(spec rkport.Spec) []rkport.Spec {
specs := []rkport.Spec{spec}
protocol := spec.Proto
if machine.MachineHostType() != machine.Wsl || strings.HasSuffix(protocol, "4") || strings.HasSuffix(protocol, "6") {
if machine.HostType() != machine.Wsl || strings.HasSuffix(protocol, "4") || strings.HasSuffix(protocol, "6") {
return specs
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.3.0
github.com/containers/buildah v1.33.2-0.20231121195905-d1a1c53c8e1c
github.com/containers/common v0.57.1-0.20231121115347-e2da7bec2245
github.com/containers/common v0.57.1-0.20231127171932-3cec82a37105
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/gvisor-tap-vsock v0.7.1
github.com/containers/image/v5 v5.29.1-0.20231120202631-293b00ba7166
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ github.com/containernetworking/plugins v1.3.0 h1:QVNXMT6XloyMUoO2wUOqWTC1hWFV62Q
github.com/containernetworking/plugins v1.3.0/go.mod h1:Pc2wcedTQQCVuROOOaLBPPxrEXqqXBFt3cZ+/yVg6l0=
github.com/containers/buildah v1.33.2-0.20231121195905-d1a1c53c8e1c h1:E7nxvH3N3kpyson0waJv1X+eY9hAs+x2zQswsK+//yY=
github.com/containers/buildah v1.33.2-0.20231121195905-d1a1c53c8e1c/go.mod h1:oMNfVrZGEfWVOxXTNOYPMdZzDfSo2umURK/TO0d8TRk=
github.com/containers/common v0.57.1-0.20231121115347-e2da7bec2245 h1:JjjvtSd5dwt8CRZX9eZyxNx9IKnE6TT5qYuDqePk2n4=
github.com/containers/common v0.57.1-0.20231121115347-e2da7bec2245/go.mod h1:5C4EkX50fgbJZdZPdX3QSVGbXIe3wuhWz1G7e5JBxbs=
github.com/containers/common v0.57.1-0.20231127171932-3cec82a37105 h1:CMtIWhUBDpOFPNUDiYUYiWC5ducrYPdynWAsB4jAX8k=
github.com/containers/common v0.57.1-0.20231127171932-3cec82a37105/go.mod h1:9gSqpih8l6jSGOC0D28Bic4Yx1GuYKFH+MUZhr+sGkg=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/gvisor-tap-vsock v0.7.1 h1:+Rc+sOPplrkQb/BUXeN0ug8TxjgyrIqo/9P/eNS2A4c=
Expand Down
9 changes: 5 additions & 4 deletions pkg/machine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"
"time"

"github.com/containers/common/pkg/machine"
"github.com/containers/podman/v4/pkg/machine/compression"
"github.com/containers/podman/v4/pkg/machine/define"
"github.com/containers/storage/pkg/homedir"
Expand Down Expand Up @@ -352,13 +353,13 @@ const (
func (v VMType) String() string {
switch v {
case WSLVirt:
return "wsl"
return machine.Wsl
case AppleHvVirt:
return "applehv"
return machine.AppleHV
case HyperVVirt:
return "hyperv"
return machine.HyperV
}
return "qemu"
return machine.Qemu
}

type APIForwardingState int
Expand Down
7 changes: 3 additions & 4 deletions pkg/machine/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {

ignStorage := Storage{
Directories: getDirs(ign.Name),
Files: getFiles(ign.Name, ign.UID, ign.Rootful),
Files: getFiles(ign.Name, ign.UID, ign.Rootful, ign.VMType),
Links: getLinks(ign.Name),
}

Expand Down Expand Up @@ -300,7 +300,7 @@ func getDirs(usrName string) []Directory {
return dirs
}

func getFiles(usrName string, uid int, rootful bool) []File {
func getFiles(usrName string, uid int, rootful bool, vmtype VMType) []File {
files := make([]File, 0)

lingerExample := `[Unit]
Expand Down Expand Up @@ -434,8 +434,7 @@ Delegate=memory pids cpu io
FileEmbedded1: FileEmbedded1{
Append: nil,
Contents: Resource{
// TODO this should be fixed for all vmtypes
Source: EncodeDataURLPtr("qemu\n"),
Source: EncodeDataURLPtr(fmt.Sprintf("%s\n", vmtype.String())),
},
Mode: IntToPtr(0644),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/specgen/winpath_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func shouldResolveWinPaths() bool {
return machine.MachineHostType() == "wsl"
return machine.HostType() == "wsl"
}

func shouldResolveUnixWinVariant(path string) bool {
Expand Down
24 changes: 10 additions & 14 deletions vendor/github.com/containers/common/pkg/machine/machine.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/pkg/volumes
github.com/containers/buildah/util
# github.com/containers/common v0.57.1-0.20231121115347-e2da7bec2245
# github.com/containers/common v0.57.1-0.20231127171932-3cec82a37105
## explicit; go 1.18
github.com/containers/common/internal/attributedstring
github.com/containers/common/libimage
Expand Down

0 comments on commit 443e779

Please sign in to comment.