Repository: cloudstack
Updated Branches:
refs/heads/master 8a3793c58 -> f0e82f340
CLOUDSTACK-7543: Attach RBD disk for LXC during start. Moved rbd map code
seperate method. When adding block device, qemu driver should not be used for
LXC
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f0e82f34
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f0e82f34
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f0e82f34
Branch: refs/heads/master
Commit: f0e82f340aa1a470aebbd5900aca6693211fbb08
Parents: 8a3793c
Author: Kishan Kavala
Authored: Mon Sep 15 10:15:54 2014 +0530
Committer: Kishan Kavala
Committed: Mon Sep 15 10:15:54 2014 +0530
--
.../kvm/resource/LibvirtComputingResource.java | 33 +---
.../hypervisor/kvm/resource/LibvirtVMDef.java | 20 ++--
.../kvm/storage/KVMStorageProcessor.java| 11 ++-
3 files changed, 49 insertions(+), 15 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f0e82f34/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 d608707..a79526a 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
@@ -3982,16 +3982,29 @@ public class LibvirtComputingResource extends
ServerResourceBase implements Serv
}
}
-// For LXC, find and add the root filesystem
+// For LXC, find and add the root filesystem, rbd data disks
if
(HypervisorType.LXC.toString().toLowerCase().equals(vm.getHvsType())) {
for (DiskTO volume : disks) {
+DataTO data = volume.getData();
+PrimaryDataStoreTO store =
(PrimaryDataStoreTO)data.getDataStore();
if (volume.getType() == Volume.Type.ROOT) {
-DataTO data = volume.getData();
-PrimaryDataStoreTO store =
(PrimaryDataStoreTO)data.getDataStore();
KVMPhysicalDisk physicalDisk =
_storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(),
data.getPath());
FilesystemDef rootFs = new
FilesystemDef(physicalDisk.getPath(), "/");
vm.getDevices().addDevice(rootFs);
-break;
+} else if (volume.getType() == Volume.Type.DATADISK) {
+KVMPhysicalDisk physicalDisk =
_storagePoolMgr.getPhysicalDisk(store.getPoolType(), store.getUuid(),
data.getPath());
+KVMStoragePool pool = physicalDisk.getPool();
+if(StoragePoolType.RBD.equals(pool.getType())) {
+int devId = volume.getDiskSeq().intValue();
+String device = mapRbdDevice(physicalDisk);
+if (device != null) {
+s_logger.debug("RBD device on host is: " + device);
+DiskDef diskdef = new DiskDef();
+diskdef.defBlockBasedDisk(device, devId,
DiskDef.diskBus.VIRTIO);
+diskdef.setQemuDriver(false);
+vm.getDevices().addDevice(diskdef);
+}
+}
}
}
}
@@ -5241,4 +5254,16 @@ public class LibvirtComputingResource extends
ServerResourceBase implements Serv
return true;
}
+public String mapRbdDevice(KVMPhysicalDisk disk){
+KVMStoragePool pool = disk.getPool();
+//Check if rbd image is already mapped
+String[] splitPoolImage = disk.getPath().split("/");
+String device = Script.runSimpleBashScript("rbd showmapped | grep
\""+splitPoolImage[0]+"[ ]*"+splitPoolImage[1]+"\" | grep -o \"[^ ]*[ ]*$\"");
+if(device == null) {
+//If not mapped, map and return mapped device
+String mapRbd = Script.runSimpleBashScript("rbd map " +
disk.getPath() + " --id "+pool.getAuthUserName());
+device = Script.runSimpleBashScript("rbd showmapped | grep
\""+splitPoolImage[0]+"[ ]*"+splitPoolImage[1]+"\" | grep -o \"[^ ]*[ ]*$\"");
+}
+return device;
+}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f0e82f34/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
--
diff --git
a/plugins/hypervis