Signed-off-by: Darren Stahl <darst@microsoft.com>
| ... | ... |
@@ -32,12 +32,19 @@ import ( |
| 32 | 32 |
"github.com/docker/docker/pkg/longpath" |
| 33 | 33 |
"github.com/docker/docker/pkg/reexec" |
| 34 | 34 |
"github.com/docker/docker/pkg/system" |
| 35 |
+ "github.com/docker/go-units" |
|
| 35 | 36 |
"github.com/vbatts/tar-split/tar/storage" |
| 36 | 37 |
) |
| 37 | 38 |
|
| 38 | 39 |
// filterDriver is an HCSShim driver type for the Windows Filter driver. |
| 39 | 40 |
const filterDriver = 1 |
| 40 | 41 |
|
| 42 |
+var ( |
|
| 43 |
+ vmcomputedll = syscall.NewLazyDLL("vmcompute.dll")
|
|
| 44 |
+ hcsExpandSandboxSize = vmcomputedll.NewProc("ExpandSandboxSize")
|
|
| 45 |
+ hcsSandboxSizeSupported = hcsExpandSandboxSize.Find() == nil |
|
| 46 |
+) |
|
| 47 |
+ |
|
| 41 | 48 |
// init registers the windows graph drivers to the register. |
| 42 | 49 |
func init() {
|
| 43 | 50 |
graphdriver.Register("windowsfilter", InitFilter)
|
| ... | ... |
@@ -118,10 +125,6 @@ func (d *Driver) Create(id, parent, mountLabel string, storageOpt map[string]str |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 | 120 |
func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt map[string]string) error {
|
| 121 |
- if len(storageOpt) != 0 {
|
|
| 122 |
- return fmt.Errorf("--storage-opt is not supported for windows")
|
|
| 123 |
- } |
|
| 124 |
- |
|
| 125 | 121 |
rPId, err := d.resolveID(parent) |
| 126 | 122 |
if err != nil {
|
| 127 | 123 |
return err |
| ... | ... |
@@ -184,6 +187,17 @@ func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt |
| 184 | 184 |
if err := hcsshim.CreateSandboxLayer(d.info, id, parentPath, layerChain); err != nil {
|
| 185 | 185 |
return err |
| 186 | 186 |
} |
| 187 |
+ |
|
| 188 |
+ storageOptions, err := parseStorageOpt(storageOpt) |
|
| 189 |
+ if err != nil {
|
|
| 190 |
+ return fmt.Errorf("Failed to parse storage options - %s", err)
|
|
| 191 |
+ } |
|
| 192 |
+ |
|
| 193 |
+ if hcsSandboxSizeSupported {
|
|
| 194 |
+ if err := hcsshim.ExpandSandboxSize(d.info, id, storageOptions.size); err != nil {
|
|
| 195 |
+ return err |
|
| 196 |
+ } |
|
| 197 |
+ } |
|
| 187 | 198 |
} |
| 188 | 199 |
|
| 189 | 200 |
if _, err := os.Lstat(d.dir(parent)); err != nil {
|
| ... | ... |
@@ -851,3 +865,27 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
|
| 851 | 851 |
|
| 852 | 852 |
return &fileGetCloserWithBackupPrivileges{d.dir(id)}, nil
|
| 853 | 853 |
} |
| 854 |
+ |
|
| 855 |
+type storageOptions struct {
|
|
| 856 |
+ size uint64 |
|
| 857 |
+} |
|
| 858 |
+ |
|
| 859 |
+func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
|
|
| 860 |
+ options := storageOptions{}
|
|
| 861 |
+ |
|
| 862 |
+ // Read size to change the block device size per container. |
|
| 863 |
+ for key, val := range storageOpt {
|
|
| 864 |
+ key := strings.ToLower(key) |
|
| 865 |
+ switch key {
|
|
| 866 |
+ case "size": |
|
| 867 |
+ size, err := units.RAMInBytes(val) |
|
| 868 |
+ if err != nil {
|
|
| 869 |
+ return nil, err |
|
| 870 |
+ } |
|
| 871 |
+ options.size = uint64(size) |
|
| 872 |
+ default: |
|
| 873 |
+ return nil, fmt.Errorf("Unknown storage option: %s", key)
|
|
| 874 |
+ } |
|
| 875 |
+ } |
|
| 876 |
+ return &options, nil |
|
| 877 |
+} |
| ... | ... |
@@ -185,7 +185,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e |
| 185 | 185 |
Storage: &windowsoci.Storage{
|
| 186 | 186 |
Bps: &c.HostConfig.IOMaximumBandwidth, |
| 187 | 187 |
Iops: &c.HostConfig.IOMaximumIOps, |
| 188 |
- //TODO SandboxSize: ..., |
|
| 189 | 188 |
}, |
| 190 | 189 |
} |
| 191 | 190 |
return (*libcontainerd.Spec)(&s), nil |
| ... | ... |
@@ -155,7 +155,7 @@ Set storage driver options per container. |
| 155 | 155 |
|
| 156 | 156 |
This (size) will allow to set the container rootfs size to 120G at creation time. |
| 157 | 157 |
User cannot pass a size less than the Default BaseFS Size. This option is only |
| 158 |
-available for the `devicemapper`, `btrfs`, and `zfs` graph drivers. |
|
| 158 |
+available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers. |
|
| 159 | 159 |
|
| 160 | 160 |
### Specify isolation technology for container (--isolation) |
| 161 | 161 |
|
| ... | ... |
@@ -187,7 +187,7 @@ The `-w` lets the command being executed inside directory given, here |
| 187 | 187 |
|
| 188 | 188 |
This (size) will allow to set the container rootfs size to 120G at creation time. |
| 189 | 189 |
User cannot pass a size less than the Default BaseFS Size. This option is only |
| 190 |
-available for the `devicemapper`, `btrfs`, and `zfs` graph drivers. |
|
| 190 |
+available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers. |
|
| 191 | 191 |
|
| 192 | 192 |
### Mount tmpfs (--tmpfs) |
| 193 | 193 |
|
| ... | ... |
@@ -74,9 +74,6 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio |
| 74 | 74 |
if spec.Windows.Resources.Storage.Iops != nil {
|
| 75 | 75 |
configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops |
| 76 | 76 |
} |
| 77 |
- if spec.Windows.Resources.Storage.SandboxSize != nil {
|
|
| 78 |
- configuration.StorageSandboxSize = *spec.Windows.Resources.Storage.SandboxSize |
|
| 79 |
- } |
|
| 80 | 77 |
} |
| 81 | 78 |
} |
| 82 | 79 |
|