use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class VmHandlerTest method populateVmWithDisks.
private void populateVmWithDisks(List<Disk> disks, VM vm) {
vmHandler.updateDisksForVm(vm, disks);
for (Disk disk : disks) {
VmDevice device = new VmDevice(new VmDeviceId(disk.getId(), vm.getId()), VmDeviceGeneralType.DISK, VmDeviceType.DISK.getName(), "", null, true, true, false, "", null, disk.getDiskStorageType() == DiskStorageType.IMAGE ? ((DiskImage) disk).getSnapshotId() : null, null);
vm.getManagedVmDeviceMap().put(disk.getId(), device);
}
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class ImportVmCommandTest method addSoundDeviceToVm.
private void addSoundDeviceToVm(VM vm) {
Guid deviceId = Guid.newGuid();
Map<String, Object> specParams = new HashMap<>();
VmDevice sound = new VmDevice(new VmDeviceId(deviceId, vm.getId()), VmDeviceGeneralType.SOUND, "", null, specParams, true, true, true, null, null, null, null);
vm.getManagedVmDeviceMap().put(deviceId, sound);
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class ImportVmCommandTest method addBalloonToVm.
void addBalloonToVm(VM vm) {
Guid deviceId = Guid.newGuid();
Map<String, Object> specParams = new HashMap<>();
specParams.put(VdsProperties.Model, VdsProperties.Virtio);
VmDevice balloon = new VmDevice(new VmDeviceId(deviceId, vm.getId()), VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON.toString(), null, specParams, true, true, true, null, null, null, null);
vm.getManagedVmDeviceMap().put(deviceId, balloon);
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class VmDeviceCommonUtilsTest method createNetworkInterfaceDevice.
private VmDevice createNetworkInterfaceDevice(boolean plugged, Guid id) {
VmDevice device = new VmDevice();
device.setType(VmDeviceGeneralType.INTERFACE);
device.setDevice(VmDeviceType.BRIDGE.getName());
device.setPlugged(plugged);
device.setId(new VmDeviceId(id, null));
return device;
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method writeDisks.
private void writeDisks(List<VmDevice> devices) {
Map<VmDeviceId, VmDevice> deviceIdToDevice = devices.stream().collect(Collectors.toMap(VmDevice::getId, dev -> dev));
Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(vm);
Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(vm);
int hdIndex = -1;
int sdIndex = -1;
int vdIndex = -1;
int pinnedDriveIndex = 0;
Map<Disk, VmDevice> vmDisksToDevices = vm.getDiskMap().values().stream().map(d -> new Pair<>(d, deviceIdToDevice.get(new VmDeviceId(d.getId(), vm.getId())))).filter(p -> p.getSecond() != null && p.getSecond().isManaged()).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
for (Entry<Disk, VmDevice> diskAndDevice : vmInfoBuildUtils.getSortedDisks(vmDisksToDevices, vm.getId())) {
Disk disk = diskAndDevice.getKey();
VmDevice device = diskAndDevice.getValue();
DiskVmElement dve = disk.getDiskVmElementForVm(vm.getId());
DiskInterface diskInterface = dve.getDiskInterface();
int index = 0;
int pinTo = 0;
switch(diskInterface) {
case IDE:
index = hdIndex = skipCdIndices(++hdIndex, diskInterface);
break;
case VirtIO:
pinTo = vmInfoBuildUtils.pinToIoThreads(vm, pinnedDriveIndex++);
index = vdIndex = skipCdIndices(++vdIndex, diskInterface);
break;
case SPAPR_VSCSI:
case VirtIO_SCSI:
vmInfoBuildUtils.calculateAddressForScsiDisk(vm, disk, device, vmDeviceSpaprVscsiUnitMap, vmDeviceVirtioScsiUnitMap);
case SATA:
index = sdIndex = skipCdIndices(++sdIndex, diskInterface);
break;
}
String dev = vmInfoBuildUtils.makeDiskName(dve.getDiskInterface().getName(), index);
writeDisk(device, disk, dve, dev, pinTo);
}
}
Aggregations