use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class BackendDiskAttachmentsResource method getAddParameters.
private ActionParametersBase getAddParameters(DiskAttachment attachment, org.ovirt.engine.core.common.businessentities.storage.Disk entity, Disk disk) {
DiskVmElement dve = map(attachment);
dve.getId().setVmId(vmId);
AddDiskParameters parameters = new AddDiskParameters(dve, entity);
Guid storageDomainId = getStorageDomainId(disk);
if (storageDomainId != null) {
parameters.setStorageDomainId(storageDomainId);
}
if (attachment.isSetActive()) {
parameters.setPlugDiskToVm(attachment.isActive());
}
if (disk.isSetLunStorage() && disk.getLunStorage().isSetHost()) {
parameters.setVdsId(getHostId(disk.getLunStorage().getHost()));
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class OvfOvirtWriter method writeDisk.
@Override
protected void writeDisk(DiskImage image) {
DiskVmElement dve = image.getDiskVmElementForVm(vmBase.getId());
_writer.writeAttributeString(getOvfUri(), "diskId", image.getImageId().toString());
_writer.writeAttributeString(getOvfUri(), "size", String.valueOf(bytesToGigabyte(image.getSize())));
_writer.writeAttributeString(getOvfUri(), "actual_size", String.valueOf(bytesToGigabyte(image.getActualSizeInBytes())));
_writer.writeAttributeString(getOvfUri(), "vm_snapshot_id", (image.getVmSnapshotId() != null) ? image.getVmSnapshotId().toString() : "");
writeDiskParentRef(image);
_writer.writeAttributeString(getOvfUri(), "fileRef", OvfParser.createImageFile(image));
_writer.writeAttributeString(getOvfUri(), "format", getVolumeImageFormat(image.getVolumeFormat()));
_writer.writeAttributeString(getOvfUri(), "volume-format", image.getVolumeFormat().toString());
_writer.writeAttributeString(getOvfUri(), "volume-type", image.getVolumeType().toString());
_writer.writeAttributeString(getOvfUri(), "disk-interface", dve.getDiskInterface().toString());
_writer.writeAttributeString(getOvfUri(), "read-only", String.valueOf(dve.isReadOnly()));
_writer.writeAttributeString(getOvfUri(), "shareable", String.valueOf(image.isShareable()));
_writer.writeAttributeString(getOvfUri(), "boot", String.valueOf(dve.isBoot()));
if (FeatureSupported.passDiscardSupported(version)) {
_writer.writeAttributeString(getOvfUri(), "pass-discard", String.valueOf(dve.isPassDiscard()));
}
if (image.getDiskAlias() != null) {
_writer.writeAttributeString(getOvfUri(), "disk-alias", image.getDiskAlias());
}
if (image.getDiskDescription() != null) {
_writer.writeAttributeString(getOvfUri(), "disk-description", image.getDiskDescription());
}
_writer.writeAttributeString(getOvfUri(), "wipe-after-delete", String.valueOf(image.isWipeAfterDelete()));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildDiskVmElementWithDiskInterfaceFromExternalProvider.
/**
* TODO: NOTE that currently there is a limitation of VDSM sending only the
* disk target dev name per each disk, therefore it will send "sdx" for 3 different
* disk interfaces: SCSI,USB and SATA.
* As a result, all those 3 mentioned disk interfaces will be mapped to SCSI
* interface in target VM.
* We need to receive the target bus name for each disk in order to differentiate.
*/
private static DiskVmElement buildDiskVmElementWithDiskInterfaceFromExternalProvider(Map<String, Object> map, DiskImage image, Guid vmId) {
DiskVmElement dve = new DiskVmElement(image.getId(), vmId);
String diskDevName = (String) map.get(VdsProperties.DISK_TARGET_DEV_NAME);
diskDevName = (diskDevName == null || diskDevName.length() < 3) ? "" : diskDevName.substring(0, 2);
switch(diskDevName) {
case "sd":
dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
break;
case "hd":
dve.setDiskInterface(DiskInterface.IDE);
break;
case "vd":
default:
dve.setDiskInterface(DiskInterface.VirtIO);
}
return dve;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class HotPlugDiskVDSCommand method initDriveData.
private Map<String, Object> initDriveData() {
Map<String, Object> drive = new HashMap<>();
Disk disk = getParameters().getDisk();
VmDevice vmDevice = getParameters().getVmDevice();
drive.put(VdsProperties.Type, VmDeviceType.DISK.getName());
drive.put(VdsProperties.Address, getParameters().getAddressMap() != null ? getParameters().getAddressMap() : StringUtils.EMPTY);
drive.put(VdsProperties.INTERFACE, getParameters().getDiskInterface().getName());
if (FeatureSupported.passDiscardSupported(getParameters().getVm().getCompatibilityVersion())) {
drive.put(VdsProperties.DISCARD, getParameters().isPassDiscard());
}
int numOfIoThreads = getParameters().getVm().getNumOfIoThreads();
if (numOfIoThreads != 0 && getParameters().getDiskInterface() == DiskInterface.VirtIO) {
if (vmDevice.getSpecParams() == null) {
vmDevice.setSpecParams(new HashMap<>());
}
List<DiskVmElement> diskVmElements = diskVmElementDao.getAllPluggedToVm(getParameters().getVmId());
int numOfAttachedVirtioInterfaces = 0;
for (DiskVmElement dve : diskVmElements) {
if (dve.getDiskInterface() == DiskInterface.VirtIO) {
numOfAttachedVirtioInterfaces++;
}
}
int pinToIoThread = numOfAttachedVirtioInterfaces % numOfIoThreads + 1;
vmDevice.getSpecParams().put(VdsProperties.pinToIoThread, pinToIoThread);
}
drive.put(VdsProperties.Shareable, (vmDevice.getSnapshotId() != null) ? VdsProperties.Transient : String.valueOf(disk.isShareable()));
drive.put(VdsProperties.Optional, Boolean.FALSE.toString());
drive.put(VdsProperties.ReadOnly, String.valueOf(vmDevice.getReadOnly()));
drive.put(VdsProperties.DeviceId, vmDevice.getId().getDeviceId().toString());
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
drive.put(VdsProperties.DiskType, vmInfoBuildUtils.getDiskType(getParameters().getVm(), diskImage));
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
drive.put(VdsProperties.Format, diskImage.getVolumeFormat().toString().toLowerCase());
drive.put(VdsProperties.DomainId, diskImage.getStorageIds().get(0).toString());
drive.put(VdsProperties.PoolId, diskImage.getStoragePoolId().toString());
drive.put(VdsProperties.VolumeId, diskImage.getImageId().toString());
drive.put(VdsProperties.ImageId, diskImage.getId().toString());
drive.put(VdsProperties.PropagateErrors, disk.getPropagateErrors().toString().toLowerCase());
vmInfoBuildUtils.handleIoTune(vmDevice, vmInfoBuildUtils.loadStorageQos(diskImage));
if (vmDevice.getSpecParams() != null) {
drive.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
}
break;
case LUN:
LunDisk lunDisk = (LunDisk) disk;
// If SCSI pass-through is enabled (VirtIO-SCSI/DirectLUN disk and SGIO is defined),
// set device type as 'lun' (instead of 'disk') and set the specified SGIO
boolean isVirtioScsi = getParameters().getDiskInterface() == DiskInterface.VirtIO_SCSI;
boolean isScsiPassthrough = getParameters().getDisk().isScsiPassthrough();
if (isVirtioScsi) {
if (isScsiPassthrough) {
drive.put(VdsProperties.Device, VmDeviceType.LUN.getName());
drive.put(VdsProperties.Sgio, getParameters().getDisk().getSgio().toString().toLowerCase());
} else {
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
}
} else {
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
}
drive.put(VdsProperties.Guid, lunDisk.getLun().getLUNId());
drive.put(VdsProperties.Format, VolumeFormat.RAW.toString().toLowerCase());
drive.put(VdsProperties.PropagateErrors, PropagateErrors.Off.toString().toLowerCase());
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
vmInfoBuildUtils.buildCinderDisk(cinderDisk, drive);
drive.put(VdsProperties.Device, VmDeviceType.DISK.getName());
break;
}
return drive;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class VmValidatorTest method canDisableVirtioScsiSuccess.
@Test
public void canDisableVirtioScsiSuccess() {
Disk disk = new DiskImage();
DiskVmElement dve = new DiskVmElement(disk.getId(), vm.getId());
dve.setDiskInterface(DiskInterface.VirtIO);
disk.setDiskVmElements(Collections.singletonList(dve));
assertThat(validator.canDisableVirtioScsi(Collections.singletonList(disk)), isValid());
}
Aggregations