ia64/xen-unstable

changeset 14788:3565e4883548

Make host.sched_policy read-only. Added docs, bindings, and a test for
host.cpu_configuration and host.sched_policy.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Apr 09 12:20:35 2007 +0100 (2007-04-09)
parents 51678fab4b0f
children 4add9eb83f7f
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_host.h tools/libxen/src/xen_host.c tools/libxen/test/test_bindings.c tools/python/xen/xend/XendAPI.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Mon Apr 09 11:39:27 2007 +0100
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Mon Apr 09 12:20:35 2007 +0100
     1.3 @@ -4744,6 +4744,8 @@ Quals & Field & Type & Description \\
     1.4  $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
     1.5  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
     1.6  $\mathit{RO}_\mathit{run}$ &  {\tt capabilities} & string Set & Xen capabilities \\
     1.7 +$\mathit{RO}_\mathit{run}$ &  {\tt cpu\_configuration} & (string $\rightarrow$ string) Map & The CPU configuration on this host.  May contain keys such as ``nr\_nodes'', ``sockets\_per\_node'', ``cores\_per\_socket'', or ``threads\_per\_core'' \\
     1.8 +$\mathit{RO}_\mathit{run}$ &  {\tt sched\_policy} & string & Scheduler policy currently in force on this host \\
     1.9  $\mathit{RO}_\mathit{run}$ &  {\tt supported\_bootloaders} & string Set & a list of the bootloaders installed on the machine \\
    1.10  $\mathit{RO}_\mathit{run}$ &  {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\
    1.11  $\mathit{RW}$ &  {\tt logging} & (string $\rightarrow$ string) Map & logging configuration \\
    1.12 @@ -5552,6 +5554,70 @@ value of the field
    1.13  \vspace{0.3cm}
    1.14  \vspace{0.3cm}
    1.15  \vspace{0.3cm}
    1.16 +\subsubsection{RPC name:~get\_cpu\_configuration}
    1.17 +
    1.18 +{\bf Overview:} 
    1.19 +Get the cpu\_configuration field of the given host.
    1.20 +
    1.21 + \noindent {\bf Signature:} 
    1.22 +\begin{verbatim} ((string -> string) Map) get_cpu_configuration (session_id s, host ref self)\end{verbatim}
    1.23 +
    1.24 +
    1.25 +\noindent{\bf Arguments:}
    1.26 +
    1.27 + 
    1.28 +\vspace{0.3cm}
    1.29 +\begin{tabular}{|c|c|p{7cm}|}
    1.30 + \hline
    1.31 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.32 +{\tt host ref } & self & reference to the object \\ \hline 
    1.33 +
    1.34 +\end{tabular}
    1.35 +
    1.36 +\vspace{0.3cm}
    1.37 +
    1.38 + \noindent {\bf Return Type:} 
    1.39 +{\tt 
    1.40 +(string $\rightarrow$ string) Map
    1.41 +}
    1.42 +
    1.43 +
    1.44 +value of the field
    1.45 +\vspace{0.3cm}
    1.46 +\vspace{0.3cm}
    1.47 +\vspace{0.3cm}
    1.48 +\subsubsection{RPC name:~get\_sched\_policy}
    1.49 +
    1.50 +{\bf Overview:} 
    1.51 +Get the sched\_policy field of the given host.
    1.52 +
    1.53 + \noindent {\bf Signature:} 
    1.54 +\begin{verbatim} string get_sched_policy (session_id s, host ref self)\end{verbatim}
    1.55 +
    1.56 +
    1.57 +\noindent{\bf Arguments:}
    1.58 +
    1.59 + 
    1.60 +\vspace{0.3cm}
    1.61 +\begin{tabular}{|c|c|p{7cm}|}
    1.62 + \hline
    1.63 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.64 +{\tt host ref } & self & reference to the object \\ \hline 
    1.65 +
    1.66 +\end{tabular}
    1.67 +
    1.68 +\vspace{0.3cm}
    1.69 +
    1.70 + \noindent {\bf Return Type:} 
    1.71 +{\tt 
    1.72 +string
    1.73 +}
    1.74 +
    1.75 +
    1.76 +value of the field
    1.77 +\vspace{0.3cm}
    1.78 +\vspace{0.3cm}
    1.79 +\vspace{0.3cm}
    1.80  \subsubsection{RPC name:~get\_supported\_bootloaders}
    1.81  
    1.82  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_host.h	Mon Apr 09 11:39:27 2007 +0100
     2.2 +++ b/tools/libxen/include/xen_host.h	Mon Apr 09 12:20:35 2007 +0100
     2.3 @@ -79,6 +79,8 @@ typedef struct xen_host_record
     2.4      xen_string_string_map *software_version;
     2.5      xen_string_string_map *other_config;
     2.6      struct xen_string_set *capabilities;
     2.7 +    xen_string_string_map *cpu_configuration;
     2.8 +    char *sched_policy;
     2.9      struct xen_string_set *supported_bootloaders;
    2.10      struct xen_vm_record_opt_set *resident_vms;
    2.11      xen_string_string_map *logging;
    2.12 @@ -261,6 +263,20 @@ xen_host_get_capabilities(xen_session *s
    2.13  
    2.14  
    2.15  /**
    2.16 + * Get the cpu_configuration field of the given host.
    2.17 + */
    2.18 +extern bool
    2.19 +xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host);
    2.20 +
    2.21 +
    2.22 +/**
    2.23 + * Get the sched_policy field of the given host.
    2.24 + */
    2.25 +extern bool
    2.26 +xen_host_get_sched_policy(xen_session *session, char **result, xen_host host);
    2.27 +
    2.28 +
    2.29 +/**
    2.30   * Get the supported_bootloaders field of the given host.
    2.31   */
    2.32  extern bool
     3.1 --- a/tools/libxen/src/xen_host.c	Mon Apr 09 11:39:27 2007 +0100
     3.2 +++ b/tools/libxen/src/xen_host.c	Mon Apr 09 12:20:35 2007 +0100
     3.3 @@ -73,6 +73,12 @@ static const struct_member xen_host_reco
     3.4          { .key = "capabilities",
     3.5            .type = &abstract_type_string_set,
     3.6            .offset = offsetof(xen_host_record, capabilities) },
     3.7 +        { .key = "cpu_configuration",
     3.8 +          .type = &abstract_type_string_string_map,
     3.9 +          .offset = offsetof(xen_host_record, cpu_configuration) },
    3.10 +        { .key = "sched_policy",
    3.11 +          .type = &abstract_type_string,
    3.12 +          .offset = offsetof(xen_host_record, sched_policy) },
    3.13          { .key = "supported_bootloaders",
    3.14            .type = &abstract_type_string_set,
    3.15            .offset = offsetof(xen_host_record, supported_bootloaders) },
    3.16 @@ -128,6 +134,8 @@ xen_host_record_free(xen_host_record *re
    3.17      xen_string_string_map_free(record->software_version);
    3.18      xen_string_string_map_free(record->other_config);
    3.19      xen_string_set_free(record->capabilities);
    3.20 +    xen_string_string_map_free(record->cpu_configuration);
    3.21 +    free(record->sched_policy);
    3.22      xen_string_set_free(record->supported_bootloaders);
    3.23      xen_vm_record_opt_set_free(record->resident_vms);
    3.24      xen_string_string_map_free(record->logging);
    3.25 @@ -350,6 +358,40 @@ xen_host_get_capabilities(xen_session *s
    3.26  
    3.27  
    3.28  bool
    3.29 +xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host)
    3.30 +{
    3.31 +    abstract_value param_values[] =
    3.32 +        {
    3.33 +            { .type = &abstract_type_string,
    3.34 +              .u.string_val = host }
    3.35 +        };
    3.36 +
    3.37 +    abstract_type result_type = abstract_type_string_string_map;
    3.38 +
    3.39 +    *result = NULL;
    3.40 +    XEN_CALL_("host.get_cpu_configuration");
    3.41 +    return session->ok;
    3.42 +}
    3.43 +
    3.44 +
    3.45 +bool
    3.46 +xen_host_get_sched_policy(xen_session *session, char **result, xen_host host)
    3.47 +{
    3.48 +    abstract_value param_values[] =
    3.49 +        {
    3.50 +            { .type = &abstract_type_string,
    3.51 +              .u.string_val = host }
    3.52 +        };
    3.53 +
    3.54 +    abstract_type result_type = abstract_type_string;
    3.55 +
    3.56 +    *result = NULL;
    3.57 +    XEN_CALL_("host.get_sched_policy");
    3.58 +    return session->ok;
    3.59 +}
    3.60 +
    3.61 +
    3.62 +bool
    3.63  xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host)
    3.64  {
    3.65      abstract_value param_values[] =
     4.1 --- a/tools/libxen/test/test_bindings.c	Mon Apr 09 11:39:27 2007 +0100
     4.2 +++ b/tools/libxen/test/test_bindings.c	Mon Apr 09 12:20:35 2007 +0100
     4.3 @@ -285,6 +285,40 @@ int main(int argc, char **argv)
     4.4          return 1;
     4.5      }
     4.6  
     4.7 +    xen_string_string_map *cpu_configuration;
     4.8 +    if (!xen_host_get_cpu_configuration(session, &cpu_configuration, host))
     4.9 +    {
    4.10 +        print_error(session);
    4.11 +        free(dmesg);
    4.12 +        xen_string_set_free(capabilities);
    4.13 +        xen_string_set_free(supported_bootloaders);
    4.14 +        xen_string_string_map_free(versions);
    4.15 +        xen_host_free(host);
    4.16 +        xen_vm_record_free(vm_record);
    4.17 +        xen_uuid_bytes_free(vm_uuid_bytes);
    4.18 +        xen_uuid_free(vm_uuid);
    4.19 +        xen_vm_free(vm);
    4.20 +        CLEANUP;
    4.21 +        return 1;
    4.22 +    }
    4.23 +
    4.24 +    char *sched_policy;
    4.25 +    if (!xen_host_get_sched_policy(session, &sched_policy, host))
    4.26 +    {
    4.27 +        print_error(session);
    4.28 +        xen_string_string_map_free(cpu_configuration);
    4.29 +        xen_string_set_free(capabilities);
    4.30 +        xen_string_set_free(supported_bootloaders);
    4.31 +        xen_string_string_map_free(versions);
    4.32 +        xen_host_free(host);
    4.33 +        xen_vm_record_free(vm_record);
    4.34 +        xen_uuid_bytes_free(vm_uuid_bytes);
    4.35 +        xen_uuid_free(vm_uuid);
    4.36 +        xen_vm_free(vm);
    4.37 +        CLEANUP;
    4.38 +        return 1;
    4.39 +    }
    4.40 +
    4.41      printf("%s.\n", vm_uuid);
    4.42  
    4.43      printf("In bytes, the VM UUID is ");
    4.44 @@ -318,6 +352,15 @@ int main(int argc, char **argv)
    4.45      }
    4.46      printf("\n");
    4.47  
    4.48 +    printf("Host has the following CPU configuration:\n");
    4.49 +    for (size_t i = 0; i < cpu_configuration->size; i++)
    4.50 +    {
    4.51 +        printf("  %s -> %s.\n", cpu_configuration->contents[i].key,
    4.52 +               cpu_configuration->contents[i].val);
    4.53 +    }
    4.54 +
    4.55 +    printf("Current scheduler policy: %s.\n\n", sched_policy);
    4.56 +
    4.57      printf("%s.\n", vm_record->uuid);
    4.58  
    4.59      printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle);
    4.60 @@ -334,6 +377,8 @@ int main(int argc, char **argv)
    4.61      free(dmesg);
    4.62      xen_string_set_free(supported_bootloaders);
    4.63      xen_string_set_free(capabilities);
    4.64 +    xen_string_string_map_free(cpu_configuration);
    4.65 +    free(sched_policy);
    4.66  
    4.67      print_vm_metrics(session, vm);
    4.68      if (!session->ok)
     5.1 --- a/tools/python/xen/xend/XendAPI.py	Mon Apr 09 11:39:27 2007 +0100
     5.2 +++ b/tools/python/xen/xend/XendAPI.py	Mon Apr 09 12:20:35 2007 +0100
     5.3 @@ -860,13 +860,13 @@ class XendAPI(object):
     5.4                      'metrics',
     5.5                      'capabilities',
     5.6                      'supported_bootloaders',
     5.7 +                    'sched_policy',
     5.8                      'API_version_major',
     5.9                      'API_version_minor',
    5.10                      'API_version_vendor',
    5.11                      'API_version_vendor_implementation']
    5.12      
    5.13      host_attr_rw = ['name_label',
    5.14 -                    'sched_policy',
    5.15                      'name_description',
    5.16                      'other_config']
    5.17