Skip to content

Commit cc69f4f

Browse files
committed
Don't overwrite vm settings during create from backup + nas backup fix
1 parent e03b9c0 commit cc69f4f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

scripts/vm/hypervisor/kvm/nasbackup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ done
288288
sanity_checks
289289

290290
if [ "$OP" = "backup" ]; then
291-
STATE=$(virsh -c qemu:///system list | grep $VM | awk '{print $3}')
292-
if [ "$STATE" = "running" ]; then
291+
STATE=$(virsh -c qemu:///system list | awk -v vm="$VM" '$2 == vm {print $3}')
292+
if [ -n "$STATE" ] && [ "$STATE" = "running" ]; then
293293
backup_running_vm
294294
else
295295
backup_stopped_vm

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9549,7 +9549,9 @@ public UserVm allocateVMFromBackup(CreateVMFromBackupCmd cmd) throws Insufficien
95499549
Type type = new TypeToken<Map<String, String>>(){}.getType();
95509550
Map<String, String> vmDetailsFromBackup = new Gson().fromJson(vmSettingsFromBackup, type);
95519551
for (Map.Entry<String, String> entry : vmDetailsFromBackup.entrySet()) {
9552-
vmVO.setDetail(entry.getKey(), entry.getValue());
9552+
if (!details.containsKey(entry.getKey())) {
9553+
vmVO.setDetail(entry.getKey(), entry.getValue());
9554+
}
95539555
}
95549556
_vmDao.saveDetails(vmVO);
95559557
}

0 commit comments

Comments
 (0)