use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method writeDevices.
private void writeDevices() {
List<VmDevice> devices = vmInfoBuildUtils.getVmDevices(vm.getId());
// replacement of some devices in run-once mode should eventually be done by the run-command
devices = overrideDevicesForRunOnce(devices);
devices = processPayload(devices);
devices.stream().filter(d -> d.getSpecParams() == null).forEach(d -> d.setSpecParams(Collections.emptyMap()));
writer.writeStartElement("devices");
if (vm.getClusterArch() != ArchitectureType.s390x && !(vm.getClusterArch().getFamily() == ArchitectureType.ppc && vm.getVmType() == VmType.HighPerformance)) {
// no mouse or tablet for s390x and for HP VMS with ppc architecture type
writeInput();
}
writeGuestAgentChannels();
if (vm.getClusterArch() == ArchitectureType.ppc64 || vm.getClusterArch() == ArchitectureType.ppc64le) {
writeEmulator();
}
Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
int virtioScsiIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
List<VmDevice> interfaceDevices = new ArrayList<>();
List<VmDevice> diskDevices = new ArrayList<>();
List<VmDevice> cdromDevices = new ArrayList<>();
VmDevice floppyDevice = null;
boolean spiceExists = false;
boolean balloonExists = false;
boolean forceRefreshDevices = false;
for (VmDevice device : devices) {
if (!device.isPlugged()) {
continue;
}
switch(device.getType()) {
case BALLOON:
balloonExists = true;
writeBalloon(device);
break;
case SMARTCARD:
writeSmartcard(device);
break;
case WATCHDOG:
writeWatchdog(device);
break;
case MEMORY:
// memory devices are only used for hot-plug
break;
case VIDEO:
writeVideo(device);
break;
case CONTROLLER:
switch(device.getDevice()) {
case "virtio-serial":
device.getSpecParams().put("index", 0);
device.getSpecParams().put("ports", 16);
break;
case "virtio-scsi":
device.setDevice(VdsProperties.Scsi);
device.getSpecParams().put("index", virtioScsiIndex++);
device.getSpecParams().put("model", "virtio-scsi");
break;
}
writeController(device);
break;
case GRAPHICS:
writeGraphics(device);
spiceExists = spiceExists || device.getDevice().equals("spice");
break;
case SOUND:
writeSound(device);
break;
case RNG:
writeRng(device);
break;
case CONSOLE:
writeConsole(device);
if ("serial".equals(device.getSpecParams().get("consoleType"))) {
serialConsolePath = getSerialConsolePath(device);
}
break;
case DISK:
switch(VmDeviceType.getByName(device.getDevice())) {
case CDROM:
cdromDevices.add(device);
break;
case DISK:
diskDevices.add(device);
break;
case FLOPPY:
if (floppyDevice == null || !VmPayload.isPayload(floppyDevice.getSpecParams())) {
floppyDevice = device;
}
break;
default:
}
break;
case INTERFACE:
interfaceDevices.add(device);
break;
case REDIR:
writeRedir(device);
break;
case REDIRDEV:
break;
case CHANNEL:
break;
case HOSTDEV:
HostDevice hostDevice = hostDevicesSupplier.get().get(device.getDevice());
if (hostDevice == null) {
if (!"mdev".equals(device.getDevice())) {
log.info("skipping VM host device {} for VM {}, no corresponding host device was found", device.getDevice(), device.getVmId());
}
forceRefreshDevices = true;
break;
}
writeHostDevice(device, hostDevice);
break;
case UNKNOWN:
break;
default:
break;
}
}
if (forceRefreshDevices) {
vmInfoBuildUtils.refreshVmDevices(vm.getId());
}
if (!balloonExists) {
writeDefaultBalloon();
}
writeSerialConsole(serialConsolePath);
if (spiceExists) {
writeSpiceVmcChannel();
}
updateBootOrder(diskDevices, cdromDevices, interfaceDevices);
writeInterfaces(interfaceDevices);
writeCdRom(cdromDevices);
writeFloppy(floppyDevice);
// we must write the disk after writing cd-rom and floppy to know reserved indices
writeDisks(diskDevices);
writeLeases();
writer.writeEndElement();
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class HostDeviceDaoTest method saveNetworkDevice.
@Test
public void saveNetworkDevice() {
HostDevice netDevice = generateNewEntity();
netDevice.setCapability("net");
netDevice.setNetworkInterfaceName("eth1");
dao.save(netDevice);
HostDevice result = dao.get(netDevice.getId());
assertNotNull(result);
assertEquals(netDevice, result);
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class HostDeviceDaoTest method testMarkHostDevicesUsedByVmId.
@Test
public void testMarkHostDevicesUsedByVmId() {
dao.markHostDevicesUsedByVmId(EXISTING_VM_ID, FixturesTool.VDS_RHEL6_NFS_SPM);
HostDevice hostDevice = dao.getHostDeviceByHostIdAndDeviceName(FixturesTool.VDS_RHEL6_NFS_SPM, EXISTING_DEVICE_NAME);
assertEquals(EXISTING_VM_ID, hostDevice.getVmId());
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class HostDeviceDaoTest method generateNewEntity.
@Override
protected HostDevice generateNewEntity() {
HostDevice device = new HostDevice();
device.setHostId(FixturesTool.VDS_RHEL6_NFS_SPM);
device.setDeviceName(EXISTING_DEVICE_NAME + "___child");
device.setParentDeviceName(EXISTING_DEVICE_NAME);
device.setCapability("pci");
device.setDriver("mock driver");
device.setAssignable(true);
return device;
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class HostDeviceDaoTest method testFreeHostDevicesUsedByVmId.
@Test
public void testFreeHostDevicesUsedByVmId() {
dao.freeHostDevicesUsedByVmId(EXISTING_VM_ID_2);
HostDevice hostDevice = dao.getHostDeviceByHostIdAndDeviceName(FixturesTool.VDS_RHEL6_NFS_SPM, EXISTING_DEVICE_NAME_2);
assertNull(hostDevice.getVmId());
}
Aggregations