You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2012/11/29 21:52:12 UTC
git commit: Summary: Fix orphaned patch disks for system VMs on KVM
Updated Branches:
refs/heads/master 5aad7cc30 -> 05d3f86b1
Summary: Fix orphaned patch disks for system VMs on KVM
Detail: This patch deletes any patchdisk found when deleting root volume for
system VM.
BUG-ID: CLOUDSTACK-566
Bugfix-for: 4.0.1
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1354222335 -0700
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/05d3f86b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/05d3f86b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/05d3f86b
Branch: refs/heads/master
Commit: 05d3f86b16e78de2f16ebcd368f662c8c8cfeb8a
Parents: 5aad7cc
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Thu Nov 29 13:52:15 2012 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Thu Nov 29 13:52:15 2012 -0700
----------------------------------------------------------------------
.../kvm/resource/LibvirtComputingResource.java | 28 ++++++++++----
1 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/05d3f86b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index b5af784..e0187e6 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1271,6 +1271,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements
KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol
.getPoolUuid());
pool.deletePhysicalDisk(vol.getPath());
+ String vmName = cmd.getVmName();
+ String poolPath = pool.getLocalPath();
+
+ /* if vol is a root disk for a system vm, try to remove accompanying patch disk as well
+ this is a bit tricky since the patchdisk is only a LibvirtComputingResource construct
+ and not tracked anywhere in cloudstack */
+ if (vol.getType() == Volume.Type.ROOT && vmName.matches("^[rsv]-\\d+-.+$")) {
+ File patchVbd = new File(poolPath + File.separator + vmName + "-patchdisk");
+ if(patchVbd.exists()){
+ try {
+ _storagePoolMgr.deleteVbdByPath(patchVbd.getAbsolutePath());
+ } catch(CloudRuntimeException e) {
+ s_logger.warn("unable to destroy patch disk '" + patchVbd.getAbsolutePath() +
+ "' while removing root disk for " + vmName + " : " + e);
+ }
+ } else {
+ s_logger.debug("file '" +patchVbd.getAbsolutePath()+ "' not found");
+ }
+ }
return new Answer(cmd, true, "Success");
} catch (CloudRuntimeException e) {
@@ -2651,14 +2670,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
if (disk.getDeviceType() == DiskDef.deviceType.CDROM
&& disk.getDiskPath() != null) {
cleanupDisk(conn, disk);
- } /* The clean up of patch disks should probably be done in expunge
- else if (disk.getDiskPath() != null
- && disk.getDiskPath().contains(vmName + "-patchdisk")
- && vmName.matches("^[rsv]-\\d+-VM$")) {
- if (!_storagePoolMgr.deleteVbdByPath(disk.getDiskPath())) {
- s_logger.warn("failed to delete patch disk " + disk.getDiskPath());
- }
- }*/
+ }
}
for (InterfaceDef iface: ifaces) {
_vifDriver.unplug(iface);