Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 182ef80

Browse files
committed
add StorageBaseSize in hyperd config
1 parent 20ab5d6 commit 182ef80

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

daemon/daemon.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func NewDaemon(cfg *apitypes.HyperConfig) (*Daemon, error) {
133133
return nil, err
134134
}
135135
daemon.Storage = stor
136-
daemon.Storage.Init()
136+
daemon.Storage.Init(cfg)
137137

138138
err = daemon.initRunV(cfg)
139139
if err != nil {

daemon/storage.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Storage interface {
3232
Type() string
3333
RootPath() string
3434

35-
Init() error
35+
Init(c *apitypes.HyperConfig) error
3636
CleanUp() error
3737

3838
PrepareContainer(mountId, sharedDir string, readonly bool) (*runv.VolumeDescription, error)
@@ -103,14 +103,18 @@ func (dms *DevMapperStorage) RootPath() string {
103103
return dms.rootPath
104104
}
105105

106-
func (dms *DevMapperStorage) Init() error {
106+
func (dms *DevMapperStorage) Init(c *apitypes.HyperConfig) error {
107+
size := storage.DEFAULT_DM_POOL_SIZE
108+
if cfg.StorageBaseSize > 0 {
109+
size = cfg.StorageBaseSize
110+
}
107111
dmPool := dm.DeviceMapper{
108112
Datafile: filepath.Join(utils.HYPER_ROOT, "lib") + "/data",
109113
Metadatafile: filepath.Join(utils.HYPER_ROOT, "lib") + "/metadata",
110114
DataLoopFile: storage.DEFAULT_DM_DATA_LOOP,
111115
MetadataLoopFile: storage.DEFAULT_DM_META_LOOP,
112116
PoolName: dms.VolPoolName,
113-
Size: storage.DEFAULT_DM_POOL_SIZE,
117+
Size: size,
114118
}
115119
dms.DmPoolData = &dmPool
116120
rand.Seed(time.Now().UnixNano())
@@ -289,7 +293,7 @@ func (a *AufsStorage) RootPath() string {
289293
return a.rootPath
290294
}
291295

292-
func (*AufsStorage) Init() error { return nil }
296+
func (*AufsStorage) Init(c *apitypes.HyperConfig) error { return nil }
293297

294298
func (*AufsStorage) CleanUp() error { return nil }
295299

@@ -361,7 +365,7 @@ func (o *OverlayFsStorage) RootPath() string {
361365
return o.rootPath
362366
}
363367

364-
func (*OverlayFsStorage) Init() error { return nil }
368+
func (*OverlayFsStorage) Init(c *apitypes.HyperConfig) error { return nil }
365369

366370
func (*OverlayFsStorage) CleanUp() error { return nil }
367371

@@ -437,7 +441,7 @@ func (s *BtrfsStorage) subvolumesDirID(id string) string {
437441
return filepath.Join(s.RootPath(), "subvolumes", id)
438442
}
439443

440-
func (*BtrfsStorage) Init() error { return nil }
444+
func (*BtrfsStorage) Init(c *apitypes.HyperConfig) error { return nil }
441445

442446
func (*BtrfsStorage) CleanUp() error { return nil }
443447

@@ -514,7 +518,7 @@ func (s *RawBlockStorage) RootPath() string {
514518
return s.rootPath
515519
}
516520

517-
func (s *RawBlockStorage) Init() error {
521+
func (s *RawBlockStorage) Init(c *apitypes.HyperConfig) error {
518522
if err := os.MkdirAll(filepath.Join(s.RootPath(), "volumes"), 0700); err != nil {
519523
return err
520524
}
@@ -583,7 +587,7 @@ func (v *VBoxStorage) RootPath() string {
583587
return v.rootPath
584588
}
585589

586-
func (*VBoxStorage) Init() error { return nil }
590+
func (*VBoxStorage) Init(c *apitypes.HyperConfig) error { return nil }
587591

588592
func (*VBoxStorage) CleanUp() error { return nil }
589593

types/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type HyperConfig struct {
1717
Host string
1818
GRPCHost string
1919
StorageDriver string
20+
StorageBaseSize int64
2021
VmFactoryPolicy string
2122
Driver string
2223
Kernel string
@@ -55,6 +56,7 @@ func NewHyperConfig(config string) *HyperConfig {
5556
}
5657

5758
c.StorageDriver, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "StorageDriver")
59+
c.StorageBaseSize = cfg.MustInt64(goconfig.DEFAULT_SECTION, "StorageBaseSize", 0)
5860
c.Kernel, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "Kernel")
5961
c.Initrd, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "Initrd")
6062
c.Bridge, _ = cfg.GetValue(goconfig.DEFAULT_SECTION, "Bridge")

0 commit comments

Comments
 (0)