Windows: Added support for storage-opt size

Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
Darren Stahl 2016-06-08 12:41:48 -07:00
parent 7b2b4eb40c
commit 7e5ee6d176
5 changed files with 44 additions and 10 deletions

View file

@ -32,12 +32,19 @@ import (
"github.com/docker/docker/pkg/longpath"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/system"
"github.com/docker/go-units"
"github.com/vbatts/tar-split/tar/storage"
)
// filterDriver is an HCSShim driver type for the Windows Filter driver.
const filterDriver = 1
var (
vmcomputedll = syscall.NewLazyDLL("vmcompute.dll")
hcsExpandSandboxSize = vmcomputedll.NewProc("ExpandSandboxSize")
hcsSandboxSizeSupported = hcsExpandSandboxSize.Find() == nil
)
// init registers the windows graph drivers to the register.
func init() {
graphdriver.Register("windowsfilter", InitFilter)
@ -118,10 +125,6 @@ func (d *Driver) Create(id, parent, mountLabel string, storageOpt map[string]str
}
func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt map[string]string) error {
if len(storageOpt) != 0 {
return fmt.Errorf("--storage-opt is not supported for windows")
}
rPId, err := d.resolveID(parent)
if err != nil {
return err
@ -184,6 +187,17 @@ func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt
if err := hcsshim.CreateSandboxLayer(d.info, id, parentPath, layerChain); err != nil {
return err
}
storageOptions, err := parseStorageOpt(storageOpt)
if err != nil {
return fmt.Errorf("Failed to parse storage options - %s", err)
}
if hcsSandboxSizeSupported {
if err := hcsshim.ExpandSandboxSize(d.info, id, storageOptions.size); err != nil {
return err
}
}
}
if _, err := os.Lstat(d.dir(parent)); err != nil {
@ -851,3 +865,27 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
return &fileGetCloserWithBackupPrivileges{d.dir(id)}, nil
}
type storageOptions struct {
size uint64
}
func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
options := storageOptions{}
// Read size to change the block device size per container.
for key, val := range storageOpt {
key := strings.ToLower(key)
switch key {
case "size":
size, err := units.RAMInBytes(val)
if err != nil {
return nil, err
}
options.size = uint64(size)
default:
return nil, fmt.Errorf("Unknown storage option: %s", key)
}
}
return &options, nil
}

View file

@ -185,7 +185,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
Storage: &windowsoci.Storage{
Bps: &c.HostConfig.IOMaximumBandwidth,
Iops: &c.HostConfig.IOMaximumIOps,
//TODO SandboxSize: ...,
},
}
return (*libcontainerd.Spec)(&s), nil

View file

@ -155,7 +155,7 @@ Set storage driver options per container.
This (size) will allow to set the container rootfs size to 120G at creation time.
User cannot pass a size less than the Default BaseFS Size. This option is only
available for the `devicemapper`, `btrfs`, and `zfs` graph drivers.
available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers.
### Specify isolation technology for container (--isolation)

View file

@ -187,7 +187,7 @@ The `-w` lets the command being executed inside directory given, here
This (size) will allow to set the container rootfs size to 120G at creation time.
User cannot pass a size less than the Default BaseFS Size. This option is only
available for the `devicemapper`, `btrfs`, and `zfs` graph drivers.
available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers.
### Mount tmpfs (--tmpfs)

View file

@ -74,9 +74,6 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio
if spec.Windows.Resources.Storage.Iops != nil {
configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
}
if spec.Windows.Resources.Storage.SandboxSize != nil {
configuration.StorageSandboxSize = *spec.Windows.Resources.Storage.SandboxSize
}
}
}