use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.
the class GetUnregisteredDiskQuery method fetchQcowCompat.
private boolean fetchQcowCompat(Guid storagePoolId, Guid storageDomainId, Guid diskId, Guid volumeId, DiskImage newDiskImage) {
if (newDiskImage.getVolumeFormat().equals(VolumeFormat.COW)) {
StoragePool sp = storagePoolDao.get(storagePoolId);
QemuImageInfo qemuImageInfo = null;
if (sp != null && FeatureSupported.qcowCompatSupported(sp.getCompatibilityVersion())) {
try {
qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(storagePoolId, storageDomainId, diskId, volumeId, null, true);
} catch (Exception e) {
// do nothing, an exception string will be returned since qemuImageInfo is null.
}
if (qemuImageInfo == null) {
getQueryReturnValue().setExceptionString("Failed to fetch qemu image info from storage");
return false;
}
newDiskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.
the class GetQemuImageInfoVDSCommand method buildImageEntity.
public QemuImageInfo buildImageEntity(Map<String, Object> struct) {
QemuImageInfo qemuImageInfo = new QemuImageInfo();
try {
qemuImageInfo.setImageId(getParameters().getImageId());
qemuImageInfo.setImageGroupId(getParameters().getImageGroupId());
qemuImageInfo.setStorageDomainId(getParameters().getStorageDomainId());
qemuImageInfo.setStoragePoolId(getParameters().getStoragePoolId());
if (struct.containsKey("compat")) {
qemuImageInfo.setQcowCompat(QcowCompat.forCompatValue(struct.get("compat").toString()));
}
if (struct.containsKey("format")) {
qemuImageInfo.setQemuVolumeFormat(EnumUtils.valueOf(QemuVolumeFormat.class, struct.get("format").toString(), true));
}
if (struct.containsKey("backingfile")) {
qemuImageInfo.setBackingFile(struct.get("backingfile").toString());
}
if (struct.containsKey("virtualsize")) {
qemuImageInfo.setSize(Long.parseLong(struct.get("virtualsize").toString()));
}
if (struct.containsKey("clustersize")) {
qemuImageInfo.setClusterSize(Long.parseLong(struct.get("clustersize").toString()));
}
} catch (RuntimeException ex) {
log.error("Failed building Qemu image: {}", ex.getMessage());
printReturnValue();
log.debug("Exception", ex);
qemuImageInfo = null;
}
return qemuImageInfo;
}
use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.
the class ImportVmTemplateCommand method setQcowCompat.
protected void setQcowCompat(DiskImage diskImage) {
diskImage.setQcowCompat(QcowCompat.QCOW2_V2);
if (FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
QemuImageInfo qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(diskImage.getStoragePoolId(), diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId(), null, true);
if (qemuImageInfo != null) {
diskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
}
}
imageDao.update(diskImage.getImage());
}
use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.
the class ImportVmCommand method setQcowCompat.
protected void setQcowCompat(DiskImage diskImage) {
diskImage.setQcowCompat(QcowCompat.QCOW2_V2);
if (FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
QemuImageInfo qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(diskImage.getStoragePoolId(), diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId(), null, true);
if (qemuImageInfo != null) {
diskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
}
}
imageDao.update(diskImage.getImage());
}
Aggregations