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)
| 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. |
| 1140 | func 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. |
| 1161 | type ComparableSnapshot struct { |
no test coverage detected
searching dependent graphs…