Search in sources :

Example 1 with ChipsetType

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);
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) StringUtils(org.apache.commons.lang.StringUtils) VmType(org.ovirt.engine.core.common.businessentities.VmType) VmDeviceUpdate(org.ovirt.engine.core.common.utils.VmDeviceUpdate) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) MacPoolPerCluster(org.ovirt.engine.core.bll.network.macpool.MacPoolPerCluster) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) Version(org.ovirt.engine.core.compat.Version) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) VmHandler(org.ovirt.engine.core.bll.VmHandler) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Optional(java.util.Optional) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) ReadMacPool(org.ovirt.engine.core.bll.network.macpool.ReadMacPool) Guid(org.ovirt.engine.core.compat.Guid) UsbControllerModel(org.ovirt.engine.core.common.businessentities.UsbControllerModel) HashMap(java.util.HashMap) Function(java.util.function.Function) Supplier(java.util.function.Supplier) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) HashSet(java.util.HashSet) Inject(javax.inject.Inject) VdsProperties(org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Config(org.ovirt.engine.core.common.config.Config) CompatibilityVersionUtils(org.ovirt.engine.core.common.utils.CompatibilityVersionUtils) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VM(org.ovirt.engine.core.common.businessentities.VM) ConsoleTargetType(org.ovirt.engine.core.common.businessentities.ConsoleTargetType) VirtIoRngValidator(org.ovirt.engine.core.bll.validator.VirtIoRngValidator) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) Collections(java.util.Collections) VmInterfaceManager(org.ovirt.engine.core.bll.network.VmInterfaceManager) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) UsbControllerModel(org.ovirt.engine.core.common.businessentities.UsbControllerModel)

Example 2 with ChipsetType

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));
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType)

Aggregations

ChipsetType (org.ovirt.engine.core.common.businessentities.ChipsetType)2 UsbPolicy (org.ovirt.engine.core.common.businessentities.UsbPolicy)2 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 VmHandler (org.ovirt.engine.core.bll.VmHandler)1 VmInterfaceManager (org.ovirt.engine.core.bll.network.VmInterfaceManager)1 MacPoolPerCluster (org.ovirt.engine.core.bll.network.macpool.MacPoolPerCluster)1