use of org.ovirt.engine.core.common.businessentities.ChipsetType in project ovirt-engine by oVirt.
the class VmDeviceUtils method updateNormalUsb.
private void updateNormalUsb(VmBase vmBase, ChipsetType chipset) {
final Collection<VmDevice> usbControllers = getUsbControllers(vmBase.getId());
final List<VmDevice> unmanagedControllers = usbControllers.stream().filter(d -> !d.isManaged()).collect(Collectors.toList());
final List<VmDevice> managedUsbControllers = usbControllers.stream().filter(VmDevice::isManaged).collect(Collectors.toList());
if (unmanagedControllers.size() > 0) {
acquireUnmanagedUsbController(vmBase, chipset, managedUsbControllers, unmanagedControllers);
return;
}
final UsbControllerModel controllerModel = getUsbControllerModel(vmBase, chipset);
if ((managedUsbControllers.isEmpty() && controllerModel == null) || (managedUsbControllers.size() == 1 && controllerModel != null && controllerModel.libvirtName.equals(getUsbControllerModelName(managedUsbControllers.get(0))))) {
return;
}
disableNormalUsb(vmBase.getId());
enableNormalUsb(vmBase, chipset);
}
use of org.ovirt.engine.core.common.businessentities.ChipsetType in project ovirt-engine by oVirt.
the class VmDeviceUtils method updateUsbSlots.
/*
* USB slot
*/
/**
* Update USB slots and controllers in the new VM, if USB policy of the new VM differs from one of the old VM.
* @param oldVm old configuration, may not be null, won't be modified
* @param newVm new configuration, may not be null, only devices if this entity will be modified
*/
public void updateUsbSlots(VmBase oldVm, VmBase newVm, Supplier<Cluster> clusterSupplier) {
final UsbPolicy oldUsbPolicy = oldVm.getUsbPolicy();
final UsbPolicy newUsbPolicy = newVm.getUsbPolicy();
final int oldNumberOfSlots = getUsbSlots(oldVm.getId()).size();
final int newNumberOfUsbSlots = Config.<Integer>getValue(ConfigValues.NumberOfUSBSlots);
if (UsbPolicy.DISABLED == newUsbPolicy && newVm.getVmType() == VmType.HighPerformance) {
disableAnyUsb(oldVm, newVm);
return;
}
if (UsbPolicy.DISABLED == oldUsbPolicy && UsbPolicy.ENABLED_NATIVE == newUsbPolicy) {
disableNormalUsb(newVm.getId());
enableSpiceUsb(newVm.getId(), newNumberOfUsbSlots);
return;
}
if (UsbPolicy.ENABLED_NATIVE == oldUsbPolicy && UsbPolicy.ENABLED_NATIVE == newUsbPolicy) {
updateSpiceUsb(newVm.getId(), oldNumberOfSlots, newNumberOfUsbSlots);
return;
}
ChipsetType chipset = EmulatedMachineUtils.getEffectiveChipset(newVm, clusterSupplier);
if (UsbPolicy.ENABLED_NATIVE == oldUsbPolicy && UsbPolicy.DISABLED == newUsbPolicy) {
disableSpiceUsb(newVm.getId());
enableNormalUsb(newVm, chipset);
return;
}
if (UsbPolicy.DISABLED == oldUsbPolicy && UsbPolicy.DISABLED == newUsbPolicy) {
updateNormalUsb(newVm, chipset);
return;
}
throw new RuntimeException(format("Unexpected state: oldUsbPolicy=%s, newUsbPolicy=%s", oldUsbPolicy, newUsbPolicy));
}
Aggregations