Skip to content

Commit 2867080

Browse files
widoyadvr
authored andcommitted
CLOUDSTACK-10034: Use libvirt to create new volumes and not rados-java (apache#2039)
Since libvirt 1.2.2 libvirt will properly create volumes using RBD format 2. We can use libvirt to creates the volumes which strips a bit of code from the CloudStack Agent's responsbility. RBD format 2 is already used by all volumes created by CloudStack. This format is the most recent format of RBD and is still actively being developed. This removes the support for Ubuntu 12.04 as that does not have the proper libvirt version available. Signed-off-by: Wido den Hollander wido@widodh.nl We can use libvirt to creates the volumes which strips a bit of code from the CloudStack Agent's responsbility. RBD format 2 is already used by all volumes created by CloudStack. This format is the most recent format of RBD and is still actively being developed. This removes the support for Ubuntu 12.04 as that does not have the proper libvirt version available. Signed-off-by: Wido den Hollander <wido@widodh.nl>
1 parent 6203013 commit 2867080

2 files changed

Lines changed: 19 additions & 62 deletions

File tree

debian/control

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Description: CloudStack server library
2222

2323
Package: cloudstack-agent
2424
Architecture: all
25-
Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 0.9.8), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
25+
Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 1.2.2), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
26+
Recommends: init-system-helpers
2627
Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts
2728
Description: CloudStack agent
2829
The CloudStack agent is in charge of managing shared computing resources in

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 17 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -659,25 +659,25 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
659659
s_logger.info("Attempting to create volume " + name + " (" + pool.getType().toString() + ") in pool "
660660
+ pool.getUuid() + " with size " + size);
661661

662-
switch (pool.getType()){
663-
case RBD:
664-
return createPhysicalDiskOnRBD(name, pool, format, provisioningType, size);
665-
case NetworkFilesystem:
666-
case Filesystem:
667-
switch (format){
668-
case QCOW2:
669-
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
670-
case RAW:
671-
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
672-
case DIR:
673-
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
674-
case TAR:
662+
switch (pool.getType()) {
663+
case RBD:
675664
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
665+
case NetworkFilesystem:
666+
case Filesystem:
667+
switch (format) {
668+
case QCOW2:
669+
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
670+
case RAW:
671+
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
672+
case DIR:
673+
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
674+
case TAR:
675+
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
676+
default:
677+
throw new CloudRuntimeException("Unexpected disk format is specified.");
678+
}
676679
default:
677-
throw new CloudRuntimeException("Unexpected disk format is specified.");
678-
}
679-
default:
680-
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
680+
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
681681
}
682682
}
683683

@@ -748,50 +748,6 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool
748748
return disk;
749749
}
750750

751-
private KVMPhysicalDisk createPhysicalDiskOnRBD(String name, KVMStoragePool pool,
752-
PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size) {
753-
String volPath = null;
754-
755-
/**
756-
* To have RBD function properly we want RBD images of format 2
757-
* libvirt currently defaults to format 1
758-
*
759-
* This has been fixed in libvirt 1.2.2, but that's not upstream
760-
* in all distributions
761-
*
762-
* For that reason we use the native RBD bindings to create the
763-
* RBD image until libvirt creates RBD format 2 by default
764-
*/
765-
766-
try {
767-
s_logger.info("Creating RBD image " + pool.getSourceDir() + "/" + name + " with size " + size);
768-
769-
Rados r = new Rados(pool.getAuthUserName());
770-
r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort());
771-
r.confSet("key", pool.getAuthSecret());
772-
r.confSet("client_mount_timeout", "30");
773-
r.connect();
774-
s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host"));
775-
776-
IoCTX io = r.ioCtxCreate(pool.getSourceDir());
777-
Rbd rbd = new Rbd(io);
778-
rbd.create(name, size, rbdFeatures, rbdOrder);
779-
780-
r.ioCtxDestroy(io);
781-
} catch (RadosException e) {
782-
throw new CloudRuntimeException(e.toString());
783-
} catch (RbdException e) {
784-
throw new CloudRuntimeException(e.toString());
785-
}
786-
787-
volPath = pool.getSourceDir() + "/" + name;
788-
KVMPhysicalDisk disk = new KVMPhysicalDisk(volPath, name, pool);
789-
disk.setFormat(PhysicalDiskFormat.RAW);
790-
disk.setSize(size);
791-
disk.setVirtualSize(size);
792-
return disk;
793-
}
794-
795751
@Override
796752
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
797753
// this is for managed storage that needs to prep disks prior to use

0 commit comments

Comments
 (0)