Skip to content

Commit 2d89a8f

Browse files
committed
Fix Backup Storage capacity and NAS backup without mount options
1 parent d2fb239 commit 2d89a8f

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetBackupStatsCommandWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public Answer execute(GetBackupStorageStatsCommand command, LibvirtComputingReso
6161
BackupStorageStatsAnswer answer = new BackupStorageStatsAnswer(command, false, result.second());
6262

6363
String [] stats = result.second().split("\\s+");
64-
Long total = Long.parseLong(stats[1]);
65-
Long used = Long.parseLong(stats[2]);
64+
Long total = Long.parseLong(stats[1]) * 1024;
65+
Long used = Long.parseLong(stats[2]) * 1024;
6666
answer.setTotalSize(total);
6767
answer.setUsedSize(used);
6868

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,12 @@ private String mountBackupDirectory(String backupRepoAddress, String backupRepoT
151151
String mountDirectory = String.format("%s.%s",BACKUP_TEMP_FILE_PREFIX , randomChars);
152152
try {
153153
mountDirectory = Files.createTempDirectory(mountDirectory).toString();
154-
String mountOpts = null;
155-
if (Objects.nonNull(mountOptions)) {
156-
mountOpts = mountOptions;
157-
if ("cifs".equals(backupRepoType)) {
158-
mountOpts += ",nobrl";
159-
}
160-
}
161154
String mount = String.format(MOUNT_COMMAND, backupRepoType, backupRepoAddress, mountDirectory);
162-
if (Objects.nonNull(mountOpts)) {
163-
mount += " -o " + mountOpts;
155+
if ("cifs".equals(backupRepoType)) {
156+
mountOptions += ",nobrl";
157+
}
158+
if (!mountOptions.trim().isEmpty()) {
159+
mount += " -o " + mountOptions;
164160
}
165161
Script.runSimpleBashScript(mount);
166162
} catch (Exception e) {

0 commit comments

Comments
 (0)