diff --git a/runtime.go b/runtime.go index f8dc48562a..2ae7c03a03 100644 --- a/runtime.go +++ b/runtime.go @@ -38,6 +38,7 @@ type Runtime struct { volumes *Graph srv *Server Dns []string + deviceSet DeviceSet } var sysInitPath string @@ -75,6 +76,13 @@ func (runtime *Runtime) getContainerElement(id string) *list.Element { return nil } +func (runtime *Runtime) GetDeviceSet() (DeviceSet, error) { + if runtime.deviceSet == nil { + return nil, fmt.Errorf("No device set available") + } + return runtime.deviceSet, nil +} + // Get looks for a container by the specified ID or name, and returns it. // If the container is not found, or if an error occurs, nil is returned. func (runtime *Runtime) Get(name string) *Container { @@ -438,8 +446,8 @@ func (runtime *Runtime) Commit(container *Container, repository, tag, comment, a } // FIXME: harmonize with NewGraph() -func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, error) { - runtime, err := NewRuntimeFromDirectory(flGraphPath, autoRestart) +func NewRuntime(flGraphPath string, deviceSet DeviceSet, autoRestart bool, dns []string) (*Runtime, error) { + runtime, err := NewRuntimeFromDirectory(flGraphPath, deviceSet, autoRestart) if err != nil { return nil, err } @@ -457,7 +465,7 @@ func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, e return runtime, nil } -func NewRuntimeFromDirectory(root string, autoRestart bool) (*Runtime, error) { +func NewRuntimeFromDirectory(root string, deviceSet DeviceSet, autoRestart bool) (*Runtime, error) { runtimeRepo := path.Join(root, "containers") if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) { @@ -494,6 +502,7 @@ func NewRuntimeFromDirectory(root string, autoRestart bool) (*Runtime, error) { capabilities: &Capabilities{}, autoRestart: autoRestart, volumes: volumes, + deviceSet: deviceSet, } if err := runtime.restore(); err != nil { diff --git a/runtime_test.go b/runtime_test.go index f4f5d5af1e..503f519d12 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "github.com/dotcloud/docker/utils" + "github.com/dotcloud/docker/devmapper" "io" "log" "net" @@ -87,7 +88,7 @@ func init() { NetworkBridgeIface = unitTestNetworkBridge // Make it our Store root - if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, false); err != nil { + if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, devmapper.NewDeviceSetDM(unitTestStoreBase), false); err != nil { panic(err) } else { globalRuntime = runtime @@ -456,7 +457,7 @@ func TestRestore(t *testing.T) { // Here are are simulating a docker restart - that is, reloading all containers // from scratch - runtime2, err := NewRuntimeFromDirectory(runtime1.root, false) + runtime2, err := NewRuntimeFromDirectory(runtime1.root, devmapper.NewDeviceSetDM(runtime1.root), false) if err != nil { t.Fatal(err) } diff --git a/server.go b/server.go index 295b7d80b9..1b4c0790ae 100644 --- a/server.go +++ b/server.go @@ -1298,7 +1298,7 @@ func NewServer(flGraphPath string, deviceSet DeviceSet, autoRestart, enableCors if runtime.GOARCH != "amd64" { log.Fatalf("The docker runtime currently only supports amd64 (not %s). This will change in the future. Aborting.", runtime.GOARCH) } - runtime, err := NewRuntime(flGraphPath, autoRestart, dns) + runtime, err := NewRuntime(flGraphPath, deviceSet, autoRestart, dns) if err != nil { return nil, err } diff --git a/utils_test.go b/utils_test.go index 740a5fc1bc..bc4dd65a3c 100644 --- a/utils_test.go +++ b/utils_test.go @@ -2,6 +2,7 @@ package docker import ( "github.com/dotcloud/docker/utils" + "github.com/dotcloud/docker/devmapper" "io" "io/ioutil" "os" @@ -42,7 +43,7 @@ func newTestRuntime() (*Runtime, error) { return nil, err } - runtime, err := NewRuntimeFromDirectory(root, false) + runtime, err := NewRuntimeFromDirectory(root, devmapper.NewDeviceSetDM(root), false) if err != nil { return nil, err }