From 752fbf9333148afc102848cac1138b8a8d67a400 Mon Sep 17 00:00:00 2001 From: hamistao Date: Fri, 22 Nov 2024 10:22:08 -0300 Subject: [PATCH] lxd/storage: Assume default size for block volumes when size is not set This helps get correct VM disk total size. Signed-off-by: hamistao --- lxd/storage/backend_lxd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go index fff80100ddcd..62ec945d66ca 100644 --- a/lxd/storage/backend_lxd.go +++ b/lxd/storage/backend_lxd.go @@ -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