How to enable Intel® AMT KVM by programming

The first task to perform when working with KVM is enabling the redirection ports. This post is about doing this task by code.  This use case can be divided into in three steps (as mentioned in the KVM application developer guide):

  • Check if KVM is Enabled or Disabled

  • Enable/Disable the KVM Interface

  • Change the Listener Enabled Setting


 

In the AMT SDK under “Intel®_AMT_6.0\Windows\Intel_AMT\Samples\KVM”  directory there is a sample KVM control application which can be useful when you require a guide or starting point (Figure 1) .

 

Figure 1: KVM control application.

Following code implements the three mentioned steps:

        private static WSMAN_STATUS_CODE EnableKVMCommonPart(bool enable, IPS_KVMRedirectionSettingData kvm)

        {

            if (!kvm.EnabledByMEBx)

            {

                return WSMAN_STATUS_CODE.KVM_DISABLED_IN_MEBX;

            }

            // perform request state change if needed

            CIM_RedirectionService redirectionService = new CIM_RedirectionService(WsmanOperation.GetInstance().WsmanClient);

            redirectionService.Get();

            ushort desiredState = (enable) ? (ushort)Configuration.KVM_STATE.KVM_STATE_ENABLE : (ushort)Configuration.KVM_STATE.KVM_STATE_DISABLED;

            if (redirectionService.EnabledState != desiredState)

            {

                CIM_KVMRedirectionSAP kvmSap = new CIM_KVMRedirectionSAP(WsmanOperation.GetInstance().WsmanClient);

                kvmSap.Get();

                CimReference job;

                uint status = kvmSap.RequestStateChange(desiredState, null, out job);

                if (status != 0)

                {

                    return WSMAN_STATUS_CODE.KVM_REQUEST_STATE_CHANGE_FAILED;

                }

            }

            return WSMAN_STATUS_CODE.OK;

        }

Code above first checks is KVM is enabled in the MEBx and if it is, then it requests the change of the state of the setting.  After changing the state of the KVM interface, it’s necessary to enable the listener and surprise! Listener is enabled in the same way than SOL, so my last post works fine here too.

Two things are important when working with KVM, so you should have it into account: protocol used by KVM is RealVNC* Remote Frame Buffer (RFB) and KVM Requires Active Integrated Graphics. If you need more information about KVM please review the "Keyboard, Video & Mouse Remote Control“presentation by Thomas Propst.

I’ll continue working on implications of porting AMT 3.X, 4.X and 5.X to, so keep looking at this blog for updates.

Greetings,

Javier Andrés Cáceres Alvis.

http://speechflow.spaces.live.com/

http://software.intel.com/en-us/blogs/author/javierandrescaceres/
Categories:
Tags:
For more complete information about compiler optimizations, see our Optimization Notice.

Comments

Gael Hofemeier (Intel)'s picture

Thanks for posting this, Javier!

Follow me on Twitter: @GHIntelBlogs Facebook: https://www.facebook.com/gh.intelblogs
's picture

Nice thank you!

Ho Kim (Intel)'s picture

^^) Yes, it's very useful information ..