Example #1
0
        protected override void Run()
        {
            if (_vbdMode != _vbd.mode)
            {
                VBD.set_mode(Session, _vbd.opaque_ref, _vbdMode);
            }

            if (_priority != _vbd.GetIoNice())
            {
                _vbd.SetIoNice(_priority);
                VBD.set_qos_algorithm_params(Session, _vbd.opaque_ref, _vbd.qos_algorithm_params);
            }

            if (!_changeDevicePosition)
            {
                return;
            }

            if (_other != null)
            {
                // We're going to have to do a swap

                SetUserDevice(Session, VM, _other, _vbd.userdevice, false);
                SetUserDevice(Session, VM, _vbd, _devicePosition, true);

                if (VM.power_state == vm_power_state.Running && _other.allowed_operations.Contains(vbd_operations.plug))
                {
                    VBD.plug(Session, _other.opaque_ref);
                }
            }
            else
            {
                SetUserDevice(Session, VM, _vbd, _devicePosition, false);
            }
        }