mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
CLOUDSTACK-4004: Fix attaching a newly allocated RBD image to an Instance
Signed-off-by: Wido den Hollander <wido@42on.com>
This commit is contained in:
parent
514cb91906
commit
3fb58c42c4
@ -384,7 +384,7 @@ public class LibvirtVMDef {
|
||||
}
|
||||
}
|
||||
|
||||
enum diskProtocol {
|
||||
public enum diskProtocol {
|
||||
RBD("rbd"), SHEEPDOG("sheepdog");
|
||||
String _diskProtocol;
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtDomainXMLParser;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol;
|
||||
import com.cloud.storage.JavaStorageLayer;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
@ -626,6 +627,7 @@ public class KVMStorageProcessor implements StorageProcessor {
|
||||
List<DiskDef> disks = null;
|
||||
Domain dm = null;
|
||||
DiskDef diskdef = null;
|
||||
KVMStoragePool attachingPool = attachingDisk.getPool();
|
||||
try {
|
||||
if (!attach) {
|
||||
dm = conn.domainLookupByName(vmName);
|
||||
@ -646,11 +648,17 @@ public class KVMStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
} else {
|
||||
diskdef = new DiskDef();
|
||||
if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
|
||||
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO,
|
||||
DiskDef.diskFmtType.QCOW2);
|
||||
if (attachingPool.getType() == StoragePoolType.RBD) {
|
||||
diskdef.defNetworkBasedDisk(attachingDisk.getPath(),
|
||||
attachingPool.getSourceHost(), attachingPool.getSourcePort(),
|
||||
attachingPool.getAuthUserName(), attachingPool.getUuid(), devId,
|
||||
DiskDef.diskBus.VIRTIO, diskProtocol.RBD);
|
||||
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
|
||||
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId,
|
||||
DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2);
|
||||
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
|
||||
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO);
|
||||
diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId,
|
||||
DiskDef.diskBus.VIRTIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -634,7 +634,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
format = PhysicalDiskFormat.RAW;
|
||||
|
||||
try {
|
||||
s_logger.info("Creating RBD image " + pool.getSourcePort() + "/" + name + " with size " + size);
|
||||
s_logger.info("Creating RBD image " + pool.getSourceDir() + "/" + name + " with size " + size);
|
||||
|
||||
Rados r = new Rados(pool.getAuthUserName());
|
||||
r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort());
|
||||
@ -653,7 +653,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
throw new CloudRuntimeException(e.toString());
|
||||
}
|
||||
|
||||
volPath = name;
|
||||
volPath = pool.getSourceDir() + "/" + name;
|
||||
volName = name;
|
||||
volCapacity = size;
|
||||
volAllocation = size;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user