# HG changeset patch # User Rob Hoes CP-1621: Add CLI commands for viewing and masking CPU features Signed-off-by: Rob Hoes diff -r a7d5d10ec311 ocaml/xapi/cli_frontend.ml --- a/ocaml/xapi/cli_frontend.ml Thu Jan 28 16:08:08 2010 +0000 +++ b/ocaml/xapi/cli_frontend.ml Thu Jan 28 16:38:40 2010 +0000 @@ -687,10 +687,46 @@ "host-refresh-pack-info", { reqd=["host-uuid"]; - optn=[""]; + optn=[]; help="Refreshes Host.software_version"; implementation= No_fd Cli_operations.host_refresh_pack_info; flags=[Hidden]; + }; + + "host-cpu-info", + { + reqd=[]; + optn=["host-uuid"]; + help="Lists information about the host's physical CPUs."; + implementation= No_fd Cli_operations.host_cpu_info; + flags=[]; + }; + + "host-get-cpu-features", + { + reqd=[]; + optn=["host-uuid"]; + help="Prints a hexadecimal representation of the host's physical-CPU features."; + implementation= No_fd Cli_operations.host_get_cpu_features; + flags=[]; + }; + + "host-set-cpu-features", + { + reqd=["features"]; + optn=["host-uuid"]; + help="Attempts to mask the host's physical-CPU features to match the given features. The given string must be a 32-digit hexadecimal number (optionally containing spaces), as given by host-get-cpu-features."; + implementation= No_fd Cli_operations.host_set_cpu_features; + flags=[]; + }; + + "host-reset-cpu-features", + { + reqd=[]; + optn=["host-uuid"]; + help="Removes the feature mask of the host's physical CPU (if any)."; + implementation= No_fd Cli_operations.host_reset_cpu_features; + flags=[]; }; "patch-upload", diff -r a7d5d10ec311 ocaml/xapi/cli_operations.ml --- a/ocaml/xapi/cli_operations.ml Thu Jan 28 16:08:08 2010 +0000 +++ b/ocaml/xapi/cli_operations.ml Thu Jan 28 16:38:40 2010 +0000 @@ -3527,6 +3527,42 @@ let host = Client.Host.get_by_uuid rpc session_id host_uuid in Client.Host.refresh_pack_info rpc session_id host +let host_cpu_info printer rpc session_id params = + let host = + if List.mem_assoc "host-uuid" params then + Client.Host.get_by_uuid rpc session_id (List.assoc "host-uuid" params) + else + get_host_from_session rpc session_id in + let cpu_info = Client.Host.get_cpu_info rpc session_id host in + printer (Cli_printer.PTable [cpu_info]) + +let host_get_cpu_features printer rpc session_id params = + let host = + if List.mem_assoc "host-uuid" params then + Client.Host.get_by_uuid rpc session_id (List.assoc "host-uuid" params) + else + get_host_from_session rpc session_id in + let cpu_info = Client.Host.get_cpu_info rpc session_id host in + let features = List.assoc "features" cpu_info in + printer (Cli_printer.PMsg features) + +let host_set_cpu_features printer rpc session_id params = + let host = + if List.mem_assoc "host-uuid" params then + Client.Host.get_by_uuid rpc session_id (List.assoc "host-uuid" params) + else + get_host_from_session rpc session_id in + let features = List.assoc "features" params in + Client.Host.set_cpu_features rpc session_id host features + +let host_reset_cpu_features printer rpc session_id params = + let host = + if List.mem_assoc "host-uuid" params then + Client.Host.get_by_uuid rpc session_id (List.assoc "host-uuid" params) + else + get_host_from_session rpc session_id in + Client.Host.reset_cpu_features rpc session_id host + let patch_upload fd printer rpc session_id params = let filename = List.assoc "file-name" params in let pool = Client.Pool.get_all rpc session_id in