mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
kvm: Suspending the VM prior to deleting snapshots to avoid corruption, th… (#4032)
These changes are related to PR #3194, but include suspending/resuming the VM when doing a VM snapshot as well, when deleting a VM snapshot, as it is performing the same operations via Libvirt. Also, there was an issue with the UI/localization changes in the prior PR, as that PR was altering the Volume snapshot behavior, but was altering the VM snapshot wording. Both have been altered in this PR. Issuing this in response to the work happening in PR #4029.
This commit is contained in:
parent
787491871a
commit
af0f6422ec
@ -24,7 +24,7 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.Domain;
|
||||
import org.libvirt.DomainInfo.DomainState;
|
||||
import org.libvirt.DomainInfo;
|
||||
import org.libvirt.DomainSnapshot;
|
||||
import org.libvirt.LibvirtException;
|
||||
|
||||
@ -52,18 +52,33 @@ public final class LibvirtDeleteVMSnapshotCommandWrapper extends CommandWrapper<
|
||||
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
|
||||
Domain dm = null;
|
||||
DomainSnapshot snapshot = null;
|
||||
DomainInfo.DomainState oldState = null;
|
||||
boolean tryingResume = false;
|
||||
Connect conn = null;
|
||||
try {
|
||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
|
||||
Connect conn = libvirtUtilitiesHelper.getConnection();
|
||||
conn = libvirtUtilitiesHelper.getConnection();
|
||||
dm = libvirtComputingResource.getDomain(conn, vmName);
|
||||
|
||||
snapshot = dm.snapshotLookupByName(cmd.getTarget().getSnapshotName());
|
||||
|
||||
s_logger.debug("Suspending domain " + vmName);
|
||||
dm.suspend(); // suspend the vm to avoid image corruption
|
||||
oldState = dm.getInfo().state;
|
||||
if (oldState == DomainInfo.DomainState.VIR_DOMAIN_RUNNING) {
|
||||
s_logger.debug("Suspending domain " + vmName);
|
||||
dm.suspend(); // suspend the vm to avoid image corruption
|
||||
}
|
||||
|
||||
snapshot.delete(0); // only remove this snapshot, not children
|
||||
|
||||
if (oldState == DomainInfo.DomainState.VIR_DOMAIN_RUNNING) {
|
||||
// Resume the VM
|
||||
tryingResume = true;
|
||||
dm = libvirtComputingResource.getDomain(conn, vmName);
|
||||
if (dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_PAUSED) {
|
||||
dm.resume();
|
||||
}
|
||||
}
|
||||
|
||||
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
|
||||
} catch (LibvirtException e) {
|
||||
String msg = " Delete VM snapshot failed due to " + e.toString();
|
||||
@ -97,21 +112,26 @@ public final class LibvirtDeleteVMSnapshotCommandWrapper extends CommandWrapper<
|
||||
} else if (snapshot == null) {
|
||||
s_logger.debug("Can not find vm snapshot " + cmd.getTarget().getSnapshotName() + " on vm: " + vmName + ", return true");
|
||||
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
|
||||
} else if (tryingResume) {
|
||||
s_logger.error("Failed to resume vm after delete snapshot " + cmd.getTarget().getSnapshotName() + " on vm: " + vmName + " return true : " + e);
|
||||
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
|
||||
}
|
||||
|
||||
s_logger.warn(msg, e);
|
||||
return new DeleteVMSnapshotAnswer(cmd, false, msg);
|
||||
} finally {
|
||||
if (dm != null) {
|
||||
// Make sure if the VM is paused, then resume it, in case we got an exception during our delete() and didn't have the chance before
|
||||
try {
|
||||
if (dm.getInfo().state == DomainState.VIR_DOMAIN_PAUSED) {
|
||||
dm = libvirtComputingResource.getDomain(conn, vmName);
|
||||
if (oldState == DomainInfo.DomainState.VIR_DOMAIN_RUNNING && dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_PAUSED) {
|
||||
s_logger.debug("Resuming domain " + vmName);
|
||||
dm.resume();
|
||||
}
|
||||
dm.free();
|
||||
} catch (LibvirtException l) {
|
||||
s_logger.trace("Ignoring libvirt error.", l);
|
||||
};
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.error("Failed to resume vm after delete snapshot " + cmd.getTarget().getSnapshotName() + " on vm: " + vmName + " return true : " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1031,7 +1031,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
s_logger.debug("Failed to delete snapshots on primary", ex);
|
||||
s_logger.error("Failed to delete snapshots on primary", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.",
|
||||
"message.action.stop.systemvm": "Please confirm that you want to stop this system VM.",
|
||||
"message.action.take.snapshot": "Please confirm that you want to take a snapshot of this volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Please confirm that you want to take a snapshot of this VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Please confirm that you want to unmanage the cluster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Please confirm that you want to delete this VM snapshot.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.",
|
||||
"message.action.stop.systemvm": "Please confirm that you want to stop this system VM.",
|
||||
"message.action.take.snapshot": "Please confirm that you want to take a snapshot of this volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Please confirm that you want to take a snapshot of this VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Please confirm that you want to unmanage the cluster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Please confirm that you want to delete this VM snapshot.",
|
||||
|
||||
@ -1890,6 +1890,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Alle von diesem Router angebotenen Dienste werden unterbrochen. Bitte bestätigen Sie, dass Sie diesen Router stoppen möchten.",
|
||||
"message.action.stop.systemvm": "Bitte bestätigen Sie, dass Sie diese System-VM stoppen möchten.",
|
||||
"message.action.take.snapshot": "Bitte bestätigen Sie, dass Sie einen Schnappschuss von diesem Volumen sichern möchten.",
|
||||
"message.action.snapshot.fromsnapshot":"Bitte bestätigen Sie, dass Sie einen Schnappschuss von diesem VM Schnappschuss sichern möchten.",
|
||||
"message.action.unmanage.cluster": "Bitte bestätigen Sie, dass Sie das Cluster vernachlässigen möchten.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Bitte bestätigen Sie, dass Sie diesen VM Schnappschuss löschen wollen.",
|
||||
|
||||
@ -2048,7 +2048,8 @@ var dictionary = {
|
||||
"message.action.stop.router":"All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.",
|
||||
"message.action.router.health.checks":"Health checks result will be fetched from router.",
|
||||
"message.action.stop.systemvm":"Please confirm that you want to stop this system VM.",
|
||||
"message.action.take.snapshot":"Please confirm that you want to take a snapshot of this volume.",
|
||||
"message.action.take.snapshot":"Please confirm that you want to take a snapshot of this volume.<br>Note that if this volume is in use by an instance running on KVM, the instance will be paused prior to, and resumed after creation of the snapshot",
|
||||
"message.action.snapshot.fromsnapshot":"Please confirm that you want to take a snapshot of this VM snapshot.",
|
||||
"message.action.unmanage.cluster":"Please confirm that you want to unmanage the cluster.",
|
||||
"message.action.vmsnapshot.create":"Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete":"Please confirm that you want to delete this VM snapshot. <br>Please notice that the instance will be paused before the snapshot deletion, and resumed after deletion, if it runs on KVM.",
|
||||
|
||||
@ -1889,6 +1889,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Todos los servicios provistos por este router virtual serán interrumpidos. Por favor confirmar que desea apagarlo.",
|
||||
"message.action.stop.systemvm": "Por favor, confirme que desea detener esta MV de Sistema. ",
|
||||
"message.action.take.snapshot": "Por favor, confirme que desea tomar una instantánea de este volúmen.",
|
||||
"message.action.snapshot.fromsnapshot":"Por favor, confirme que desea tomar una instantánea de este instantánea VM.",
|
||||
"message.action.unmanage.cluster": "Por favor, confirme que desea dejar de gestionar el Clúster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Por favor confirme que desea borrar esta instantánea de la MV.",
|
||||
|
||||
@ -1890,6 +1890,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Tous les services fournit par ce routeur virtuel vont être interrompus. Confirmer l'arrêt de ce routeur.",
|
||||
"message.action.stop.systemvm": "Arrêter cette VM ?",
|
||||
"message.action.take.snapshot": "Confirmer la prise d'un instantané pour ce volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Confirmer la prise d'un instantané pour ce instantané VM.",
|
||||
"message.action.unmanage.cluster": "Confirmez que vous ne voulez plus gérer le cluster",
|
||||
"message.action.vmsnapshot.create": "Veuillez confirmer que vous souhaitez prendre un instantané de cette instance. <br>Notez que l'instance sera mise en pause durant la prise de l'instantané puis remise en route une fois terminée, si elle fonctionne sur KVM.",
|
||||
"message.action.vmsnapshot.delete": "Confirmez que vous souhaitez supprimer cet instantané VM.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Minden ezzel a routerrel kapcsolatos szolgáltatás megszakad. Erősítsd meg, hogy le akarod állítani ezt a routert!",
|
||||
"message.action.stop.systemvm": "Erősítsd meg, hogy le akarod állítani ezt a rendszer VM-et!",
|
||||
"message.action.take.snapshot": "Erősítsd meg, hogy pillanatfelvételt kérsz erről a kötetről!",
|
||||
"message.action.snapshot.fromsnapshot":"Erősítsd meg, hogy pillanatfelvételt kérsz erről a VM pillanatfelvételt!",
|
||||
"message.action.unmanage.cluster": "Erősítsd meg, hogy megszakítod a fürt vezérlését!",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Erősítsd meg, hogy törölni akarod ezt a VM pillanatfelvételt!",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Tutti i servizi forniti da questo router virtuale saranno interrotti. Si prega di confermare di voler arrestare questo router.",
|
||||
"message.action.stop.systemvm": "Please confirm that you want to stop this system VM.",
|
||||
"message.action.take.snapshot": "Please confirm that you want to take a snapshot of this volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Please confirm that you want to take a snapshot of this VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Please confirm that you want to unmanage the cluster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Please confirm that you want to delete this VM snapshot.",
|
||||
|
||||
@ -1890,6 +1890,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "この仮想ルーターで提供するすべてのサービスが中断されます。このルーターを停止してもよろしいですか?",
|
||||
"message.action.stop.systemvm": "このシステム VM を停止してもよろしいですか?",
|
||||
"message.action.take.snapshot": "このボリュームのスナップショットを作成してもよろしいですか?",
|
||||
"message.action.snapshot.fromsnapshot":"このVMスナップショットのスナップショットを作成してもよろしいですか?",
|
||||
"message.action.unmanage.cluster": "クラスターを非管理対象にしてもよろしいですか?",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "この VM スナップショットを削除してもよろしいですか?",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "현재 가상 라우터로 제공하는 모든 서비스가 중단됩니다. 이 라우터를 정지하시겠습니까?",
|
||||
"message.action.stop.systemvm": "현재 시스템 VM을 정지하시겠습니까?",
|
||||
"message.action.take.snapshot": "현재 볼륨 스냅샷을 만드시겠습니까?",
|
||||
"message.action.snapshot.fromsnapshot":"이 VM 스냅 샷의 스냅 샷을 만들려는지 확인하십시오.",
|
||||
"message.action.unmanage.cluster": "클러스터를 비관리 대상으로 하시겠습니까?",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Please confirm that you want to delete this VM snapshot.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Alle tjenester levert fra denne virtuelle ruter vil bli avbrutt. Vennligst bekreft at du ønsker å stoppe denne ruteren.",
|
||||
"message.action.stop.systemvm": "Vennligst bekreft at du vil stoppe denne system VM.",
|
||||
"message.action.take.snapshot": "Vennligst bekreft at du vil ta et øyeblikksbilde av dette volumet.",
|
||||
"message.action.snapshot.fromsnapshot":"Bekreft at du vil ta et øyeblikksbilde av dette virtuelle maskinbildet.",
|
||||
"message.action.unmanage.cluster": "Vennligst bekreft at du ikke ønsker å administere klyngen.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Vennligst bekreft at du ønsker å slette dette VM øyeblikksbildet.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Als u deze router stopt zullen de diensten die gebruik maken van de router verstoord worden. Weet u zeker dat u deze actie wil uitvoeren?",
|
||||
"message.action.stop.systemvm": "Bevestig dat u deze systeem VM wilt stoppen.",
|
||||
"message.action.take.snapshot": "Bevestig dat u een snapshot wilt maken van dit volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Bevestig dat u een snapshot wilt maken van dit VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Bevestig dat u dit cluster niet langer wilt laten beheren door CloudStack.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Bevestig dat u deze VM snapshot wilt verwijderen.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.",
|
||||
"message.action.stop.systemvm": "Please confirm that you want to stop this system VM.",
|
||||
"message.action.take.snapshot": "Please confirm that you want to take a snapshot of this volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Please confirm that you want to take a snapshot of this VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Please confirm that you want to unmanage the cluster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Please confirm that you want to delete this VM snapshot.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Confirme que você deseja parar este roteador.",
|
||||
"message.action.stop.systemvm": "Confirme que você deseja parar esta VM de Sistema.",
|
||||
"message.action.take.snapshot": "Por favor confirme que você deseja criar um snapshot deste volume.",
|
||||
"message.action.snapshot.fromsnapshot":"Por favor confirme que você deseja criar um snapshot deste VM snapshot.",
|
||||
"message.action.unmanage.cluster": "Confirma a desvinculação do cluster.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Por favor, confirme que você deseja excluir este snapshot da VM.",
|
||||
|
||||
@ -1888,6 +1888,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "Подтвердите, что вы действительно хотите остановить этот роутер.",
|
||||
"message.action.stop.systemvm": "Пожалуйста подтвердите желание остановить эту служебную машину.",
|
||||
"message.action.take.snapshot": "Подтвердите, что вы действительно хотите получить снимок этого диска.",
|
||||
"message.action.snapshot.fromsnapshot":"Пожалуйста, подтвердите, что вы хотите сделать снимок этого снимка виртуальной машины.",
|
||||
"message.action.unmanage.cluster": "Подтвердите, что вы действительно хотите перевести кластер в обычный режим.",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "Пожалуйста подтвердите, что Вы хотите удалить этот снимок ВМ.",
|
||||
|
||||
@ -1890,6 +1890,7 @@ var dictionary = {
|
||||
"message.action.stop.router": "此虚拟路由器提供的所有服务都将中断。请确认您确实要停止此路由器。",
|
||||
"message.action.stop.systemvm": "请确认您确实要停止此系统 VM。",
|
||||
"message.action.take.snapshot": "请确认您确实要创建此卷的快照。",
|
||||
"message.action.snapshot.fromsnapshot":"请确认您要对此虚拟机快照制作快照。",
|
||||
"message.action.unmanage.cluster": "请确认您确实要取消托管此群集。",
|
||||
"message.action.vmsnapshot.create": "Please confirm that you want to take a snapshot of this instance. <br>Please notice that the instance will be paused during the snapshoting, and resumed after snapshotting, if it runs on KVM.",
|
||||
"message.action.vmsnapshot.delete": "请确认您确实要删除此 VM 快照。",
|
||||
|
||||
@ -2705,7 +2705,7 @@
|
||||
},
|
||||
createForm: {
|
||||
title: 'label.action.take.snapshot',
|
||||
desc: 'message.action.take.snapshot',
|
||||
desc: 'message.action.snapshot.fromsnapshot',
|
||||
fields: {
|
||||
name: {
|
||||
label: 'label.name',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user