Summary: KVM - undefine persistent VMs on stop

Detail: A previous patch fixed an issue where we are defining VMs to persist
locally on KVM hosts, which can cause issues if the agent isn't running and
libvirt decides to start the VM unbeknownst to cloudstack. The previous patch
stopped defining VMs as persistent. This patch adds compatibility for existing
cloudstack environments, removing the persistent definition on stop if needed.

BUG-ID: CLOUDSTACK-600
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1363194656 -0600
This commit is contained in:
Marcus Sorensen 2013-03-13 11:10:56 -06:00
parent 2feda05ecd
commit 8d7d1cd562

View File

@ -3937,9 +3937,13 @@ ServerResource {
try {
dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName
.getBytes()));
int persist = dm.isPersistent();
if (force) {
if (dm.getInfo().state != DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) {
dm.destroy();
if (persist == 1) {
dm.undefine();
}
}
} else {
if (dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) {
@ -3957,6 +3961,10 @@ ServerResource {
s_logger.warn("Timed out waiting for domain " + vmName
+ " to shutdown gracefully");
return Script.ERR_TIMEOUT;
} else {
if (persist == 1) {
dm.undefine();
}
}
}
} catch (LibvirtException e) {