diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go index 207709ee24..c643a320f5 100644 --- a/cmd/podman/registry/registry.go +++ b/cmd/podman/registry/registry.go @@ -12,9 +12,6 @@ import ( "github.com/spf13/cobra" ) -// DefaultRootAPIPath is the default path of the REST socket -const DefaultRootAPIPath = "/run/podman/podman.sock" - // DefaultRootAPIAddress is the default address of the REST socket with unix: prefix const DefaultRootAPIAddress = "unix:" + DefaultRootAPIPath diff --git a/cmd/podman/registry/registry_common.go b/cmd/podman/registry/registry_common.go new file mode 100644 index 0000000000..2b0cdb16f9 --- /dev/null +++ b/cmd/podman/registry/registry_common.go @@ -0,0 +1,7 @@ +//go:build !freebsd +// +build !freebsd + +package registry + +// DefaultRootAPIPath is the default path of the REST socket +const DefaultRootAPIPath = "/run/podman/podman.sock" diff --git a/cmd/podman/registry/registry_freebsd.go b/cmd/podman/registry/registry_freebsd.go new file mode 100644 index 0000000000..3529681a94 --- /dev/null +++ b/cmd/podman/registry/registry_freebsd.go @@ -0,0 +1,4 @@ +package registry + +// DefaultRootAPIPath is the default path of the REST socket +const DefaultRootAPIPath = "/var/run/podman/podman.sock" diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go index bb8156d4c5..53572234a8 100644 --- a/cmd/podman/system/service.go +++ b/cmd/podman/system/service.go @@ -1,5 +1,6 @@ -//go:build linux && !remote -// +build linux,!remote +//go:build (linux || freebsd) && !remote +// +build linux freebsd +// +build !remote package system diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go index 5c57a5df2c..f5ae6fd509 100644 --- a/cmd/podman/system/service_abi.go +++ b/cmd/podman/system/service_abi.go @@ -1,5 +1,6 @@ -//go:build linux && !remote -// +build linux,!remote +//go:build (linux || freebsd) && !remote +// +build linux freebsd +// +build !remote package system @@ -12,7 +13,6 @@ import ( "path/filepath" "github.com/containers/common/pkg/cgroups" - "github.com/containers/common/pkg/servicereaper" "github.com/containers/podman/v4/cmd/podman/registry" api "github.com/containers/podman/v4/pkg/api/server" "github.com/containers/podman/v4/pkg/domain/entities" @@ -119,7 +119,7 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities logrus.Debugf("Could not move to subcgroup: %v", err) } - servicereaper.Start() + maybeStartServiceReaper() infra.StartWatcher(libpodRuntime) server, err := api.NewServerWithSettings(libpodRuntime, listener, opts) if err != nil { diff --git a/cmd/podman/system/service_abi_common.go b/cmd/podman/system/service_abi_common.go new file mode 100644 index 0000000000..999f90fbe9 --- /dev/null +++ b/cmd/podman/system/service_abi_common.go @@ -0,0 +1,7 @@ +//go:build !linux && !remote + +package system + +// Currently, we only need servicereaper on Linux to support slirp4netns. +func maybeStartServiceReaper() { +} diff --git a/cmd/podman/system/service_abi_linux.go b/cmd/podman/system/service_abi_linux.go new file mode 100644 index 0000000000..d0da1594ad --- /dev/null +++ b/cmd/podman/system/service_abi_linux.go @@ -0,0 +1,12 @@ +//go:build linux && !remote + +package system + +import ( + "github.com/containers/common/pkg/servicereaper" +) + +// Currently, we only need servicereaper on Linux to support slirp4netns. +func maybeStartServiceReaper() { + servicereaper.Start() +} diff --git a/pkg/api/handlers/compat/containers_stats_freebsd.go b/pkg/api/handlers/compat/containers_stats_freebsd.go new file mode 100644 index 0000000000..5745547691 --- /dev/null +++ b/pkg/api/handlers/compat/containers_stats_freebsd.go @@ -0,0 +1,15 @@ +package compat + +import ( + "fmt" + "net/http" + "time" + + "github.com/containers/podman/v4/pkg/api/handlers/utils" +) + +const DefaultStatsPeriod = 5 * time.Second + +func StatsContainer(w http.ResponseWriter, r *http.Request) { + utils.Error(w, http.StatusBadRequest, fmt.Errorf("compat.StatsContainer not supported on FreeBSD")) +} diff --git a/pkg/api/handlers/compat/containers_stats.go b/pkg/api/handlers/compat/containers_stats_linux.go similarity index 100% rename from pkg/api/handlers/compat/containers_stats.go rename to pkg/api/handlers/compat/containers_stats_linux.go diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index bc5a90b912..4d2f8c303e 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -35,7 +35,7 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) { // we are reporting the default systemd activation socket path as we cannot know if a future // service may be run with another URI. if ic.Libpod.RemoteURI() == "" { - xdg := "/run" + xdg := defaultRunPath if path, err := util.GetRuntimeDir(); err != nil { // Info is as good as we can guess... return info, err diff --git a/pkg/domain/infra/abi/system_freebsd.go b/pkg/domain/infra/abi/system_freebsd.go new file mode 100644 index 0000000000..33ccebbb37 --- /dev/null +++ b/pkg/domain/infra/abi/system_freebsd.go @@ -0,0 +1,4 @@ +package abi + +// Default path for system runtime state +const defaultRunPath = "/var/run" diff --git a/pkg/domain/infra/abi/system_linux.go b/pkg/domain/infra/abi/system_linux.go new file mode 100644 index 0000000000..6a13f07050 --- /dev/null +++ b/pkg/domain/infra/abi/system_linux.go @@ -0,0 +1,4 @@ +package abi + +// Default path for system runtime state +const defaultRunPath = "/run"