mirror of https://github.com/apache/cloudstack.git
Oh, why there is so many un-compatible libvirt...
This commit is contained in:
parent
d22e144106
commit
0801da0a0f
|
|
@ -1108,10 +1108,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
s_logger.debug(result);
|
||||
new CreateAnswer(cmd, result);
|
||||
}
|
||||
|
||||
vol = createVolume(primaryPool, tmplVol);
|
||||
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, tmplVol.getPath(), volFormat.QCOW2);
|
||||
s_logger.debug(volDef.toString());
|
||||
vol = primaryPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
if (vol == null) {
|
||||
return new Answer(cmd, false, " Can't create storage volume on storage pool");
|
||||
}
|
||||
|
|
@ -3245,6 +3244,22 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
}
|
||||
}
|
||||
|
||||
private StorageVol createVolume(StoragePool destPool, StorageVol tmplVol) throws LibvirtException {
|
||||
if (isCentosHost()) {
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, null, null);
|
||||
s_logger.debug(volDef.toString());
|
||||
StorageVol vol = destPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
|
||||
/*create qcow2 image based on the name*/
|
||||
Script.runSimpleBashScript("qemu-img create -f qcow2 -b " + tmplVol.getPath() + " " + vol.getPath() );
|
||||
return vol;
|
||||
} else {
|
||||
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, tmplVol.getPath(), volFormat.QCOW2);
|
||||
s_logger.debug(volDef.toString());
|
||||
return destPool.storageVolCreateXML(volDef.toString(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private StorageVol getVolume(StoragePool pool, String volKey) {
|
||||
StorageVol vol = null;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue