mirror of
https://github.com/containers/podman.git
synced 2025-05-23 10:07:33 +08:00

this should represent the last major changes to get darwin to **compile**. again, the purpose here is to get darwin to compile so that we can eventually implement a ci task that would protect against regressions for darwin compilation. i have left the manual darwin compilation largely static still and in fact now only interject (manually) two build tags to assist with the build. trevor king has great ideas on how to make this better and i will defer final implementation of those to him. Signed-off-by: baude <bbaude@redhat.com> Closes: #1047 Approved by: rhatdan
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// +build linux
|
|
|
|
package libpod
|
|
|
|
import (
|
|
"github.com/containernetworking/plugins/pkg/ns"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type containerPlatformState struct {
|
|
|
|
// NetNSPath is the path of the container's network namespace
|
|
// Will only be set if config.CreateNetNS is true, or the container was
|
|
// told to join another container's network namespace
|
|
NetNS ns.NetNS `json:"-"`
|
|
}
|
|
|
|
func (ctr *Container) setNamespace(netNSPath string, newState *containerState) error {
|
|
if netNSPath != "" {
|
|
// Check if the container's old state has a good netns
|
|
if ctr.state.NetNS != nil && netNSPath == ctr.state.NetNS.Path() {
|
|
newState.NetNS = ctr.state.NetNS
|
|
} else {
|
|
// Tear down the existing namespace
|
|
if err := ctr.runtime.teardownNetNS(ctr); err != nil {
|
|
logrus.Warnf(err.Error())
|
|
}
|
|
|
|
// Open the new network namespace
|
|
ns, err := joinNetNS(netNSPath)
|
|
if err == nil {
|
|
newState.NetNS = ns
|
|
} else {
|
|
logrus.Errorf("error joining network namespace for container %s", ctr.ID())
|
|
ctr.valid = false
|
|
}
|
|
}
|
|
} else {
|
|
// The container no longer has a network namespace
|
|
// Tear down the old one
|
|
if err := ctr.runtime.teardownNetNS(ctr); err != nil {
|
|
logrus.Warnf(err.Error())
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (ctr *Container) setNamespaceStatePath() string {
|
|
if ctr.state.NetNS != nil {
|
|
return ctr.state.NetNS.Path()
|
|
}
|
|
return ""
|
|
}
|