Skip to content

Commit

Permalink
lxd/storage: Assume default size for block volumes when size is not set
Browse files Browse the repository at this point in the history
This helps get correct VM disk total size.

Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Nov 22, 2024
1 parent f149e2c commit 752fbf9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lxd/storage/backend_lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,12 @@ func (b *lxdBackend) GetInstanceUsage(inst instance.Instance) (*VolumeUsage, err
}

sizeStr, ok := rootDiskConf["size"]
if ok {
if !ok && vol.ContentType() == drivers.ContentTypeBlock {
// If size config key is not set, assume default size for block volumes.
sizeStr = drivers.DefaultBlockSize
}

if sizeStr != "" {
total, err := units.ParseByteSizeString(sizeStr)
if err != nil {
return nil, err
Expand Down

0 comments on commit 752fbf9

Please sign in to comment.