use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmUsbControllers.
private void buildVmUsbControllers() {
List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.CONTROLLER, VmDeviceType.USB);
for (VmDevice vmDevice : vmDevices) {
Map<String, Object> struct = new HashMap<>();
struct.put(VdsProperties.Type, vmDevice.getType().getValue());
struct.put(VdsProperties.Device, vmDevice.getDevice());
vmInfoBuildUtils.setVdsPropertiesFromSpecParams(vmDevice.getSpecParams(), struct);
struct.put(VdsProperties.SpecParams, new HashMap<String, Object>());
struct.put(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId()));
vmInfoBuildUtils.addAddress(vmDevice, struct);
String model = (String) struct.get(VdsProperties.Model);
// This is a workaround until libvirt will fix the requirement to order these controllers
if (model != null && vmInfoBuildUtils.isFirstMasterController(model)) {
devices.add(0, struct);
} else {
devices.add(struct);
}
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmDevicesFromDb.
/**
* @param deviceComparator allows to sort devices in resulting {@link #devices} list and thus
* also in libvirt domain xml. {@code null} indicates no special
* ordering.
*/
private void buildVmDevicesFromDb(VmDeviceGeneralType generalType, boolean addAddress, Map<String, Object> extraSpecParams, Comparator<VmDevice> deviceComparator) {
final List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdAndType(vm.getId(), generalType);
List<VmDevice> sortedDevices = deviceComparator == null ? vmDevices : vmDevices.stream().sorted(deviceComparator).collect(Collectors.toList());
for (VmDevice vmDevice : sortedDevices) {
Map<String, Object> struct = new HashMap<>();
struct.put(VdsProperties.Type, vmDevice.getType().getValue());
struct.put(VdsProperties.Device, vmDevice.getDevice());
Map<String, Object> specParams = vmDevice.getSpecParams();
if (extraSpecParams != null) {
specParams.putAll(extraSpecParams);
}
struct.put(VdsProperties.SpecParams, specParams);
struct.put(VdsProperties.DeviceId, String.valueOf(vmDevice.getId().getDeviceId()));
if (addAddress) {
vmInfoBuildUtils.addAddress(vmDevice, struct);
}
devices.add(struct);
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmVirtioScsi.
@Override
public void buildVmVirtioScsi() {
List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI);
Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
int virtioScsiIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
for (VmDevice vmDevice : vmDevices) {
Map<String, Object> struct = new HashMap<>();
struct.put(VdsProperties.Type, VmDeviceGeneralType.CONTROLLER.getValue());
struct.put(VdsProperties.Device, VdsProperties.Scsi);
struct.put(VdsProperties.Model, VdsProperties.VirtioScsi);
struct.put(VdsProperties.Index, Integer.toString(virtioScsiIndex));
vmInfoBuildUtils.addAddress(vmDevice, struct);
virtioScsiIndex++;
addDevice(struct, vmDevice, null);
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmRngDevice.
@Override
public void buildVmRngDevice() {
List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.RNG, VmDeviceType.VIRTIO);
for (VmDevice vmDevice : vmDevices) {
Map<String, Object> struct = new HashMap<>();
struct.put(VdsProperties.Type, VmDeviceGeneralType.RNG.getValue());
struct.put(VdsProperties.Device, VmDeviceType.VIRTIO.getName());
struct.put(VdsProperties.Model, VdsProperties.Virtio);
struct.put(VdsProperties.SpecParams, vmDevice.getSpecParams());
addDevice(struct, vmDevice, null);
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class HotPlugOrUnplugNicVDSCommand method generateDomainXml.
private String generateDomainXml() {
VmNic nic = getParameters().getNic();
VmDevice vmDevice = getParameters().getVmDevice();
LibvirtVmXmlBuilder builder = new LibvirtVmXmlBuilder(getParameters().getVm(), getVds().getId(), nic, vmDevice, vmInfoBuildUtils, nic.isPassthrough() ? Collections.singletonMap(nic.getId(), vmDevice.getHostDevice()) : Collections.emptyMap());
String libvirtXml = builder.buildHotplugNic();
String prettyLibvirtXml = XmlUtils.prettify(libvirtXml);
if (prettyLibvirtXml != null) {
log.info("NIC hot-set: {}", prettyLibvirtXml);
}
return libvirtXml;
}
Aggregations