*
* Note: This is done at configuration time,
* so it won't get updated if file size ever changes.
*/
private void updateSize() {
FileLayoutEx fileLayout = vm.getFileLayout();
// create file map to avoid unnecessary loops
Map<Integer, FileInfo> fileMap = new HashMap<Integer, FileInfo>();
if (fileLayout.getFile() != null) {
for (FileInfo fileInfo : fileLayout.getFile()) {
fileMap.put(fileInfo.getKey(), fileInfo);
}
}
sizeDetail = new HashMap<DeviceId, DiskSize>();
size = new DiskSize(0);
if (fileLayout.getSnapshot() == null) {
logger.info("missing snapshot layout in " + vm);
return;
}
// search for the snapshot's files
for (SnapshotLayout snapshotLayout : fileLayout.getSnapshot()) {
if (getMoRef().equals(snapshotLayout.getKey())) {
// loop through each disk and count the last diskunit in the chain only
// because the previous ones are shared with the other snapshots so don't double counting
VirtualDevice[] devices = getConfig().getHardware().getDevice();
for(DiskLayout disk : snapshotLayout.getDisk()) {