MCPcopy
hub / github.com/lxc/incus / InstanceDiskBlockSize

Function InstanceDiskBlockSize

internal/server/storage/utils.go:1140–1158  ·  view source on GitHub ↗

InstanceDiskBlockSize returns the block device size for the instance's disk. This will mount the instance if not already mounted and will unmount at the end if needed.

(pool Pool, inst instance.Instance, op *operations.Operation)

Source from the content-addressed store, hash-verified

1138// InstanceDiskBlockSize returns the block device size for the instance's disk.
1139// This will mount the instance if not already mounted and will unmount at the end if needed.
1140func InstanceDiskBlockSize(pool Pool, inst instance.Instance, op *operations.Operation) (int64, error) {
1141 mountInfo, err := InstanceMount(pool, inst, op)
1142 if err != nil {
1143 return -1, err
1144 }
1145
1146 defer logger.WarnOnError(func() error { return InstanceUnmount(pool, inst, op) }, "Failed to unmount instance")
1147
1148 if mountInfo.DiskPath == "" {
1149 return -1, errors.New("No disk path available from mount")
1150 }
1151
1152 blockDiskSize, err := drivers.BlockDiskSizeBytes(mountInfo.DiskPath)
1153 if err != nil {
1154 return -1, fmt.Errorf("Error getting block disk size %q: %w", mountInfo.DiskPath, err)
1155 }
1156
1157 return blockDiskSize, nil
1158}
1159
1160// ComparableSnapshot is used when comparing snapshots on different pools to see whether they differ.
1161type ComparableSnapshot struct {

Callers 2

RefreshInstanceMethod · 0.85

Calls 5

WarnOnErrorFunction · 0.92
BlockDiskSizeBytesFunction · 0.92
InstanceMountFunction · 0.85
InstanceUnmountFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…