Example #1
0
        private void VM_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            VM vm = (VM)sender;

            if (vm.uuid != Source.uuid)
            {
                return;
            }

            //We only want to reconnect the consoles when they change
            //if the vm is running and if we are using vncTerm / qemu
            if (e.PropertyName == "consoles" && vm.power_state == vm_power_state.Running && UseSource)
            {
                ConnectNewHostedConsole();
            }
            //If the consoles change under us then refresh hostedConsoles
            else if (e.PropertyName == "consoles" && vm.power_state == vm_power_state.Running && !UseSource)
            {
                lock (hostedConsolesLock)
                {
                    hostedConsoles = Source.consoles;
                }
            }
            //Or if the VM legitimately turns on
            else if (e.PropertyName == "power_state" && vm.power_state == vm_power_state.Running)
            {
                parentVNCTabView.VMPowerOn();
                ConnectNewHostedConsole();
                if (connectionPoller != null)
                {
                    connectionPoller.Change(RETRY_SLEEP_TIME, RDP_POLL_INTERVAL);
                }
            }
            else if (e.PropertyName == "power_state" &&
                     (vm.power_state == vm_power_state.Halted || vm.power_state == vm_power_state.Suspended))
            {
                parentVNCTabView.VMPowerOff();
                if (connectionPoller != null)
                {
                    connectionPoller.Change(Timeout.Infinite, Timeout.Infinite);
                }
            }
            else if (e.PropertyName == "domid")
            {
                // Reboot / start / shutdown
                Program.Invoke(this, startPolling);
            }

            if (e.PropertyName == "power_state" || e.PropertyName == "VGPUs")
            {
                parentVNCTabView.ShowGpuWarningIfRequired();
            }
        }