mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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>
This commit is contained in:
1 parent
1a2d0aa902
commit
668fbded84
5 files changed
+170
-1
No files matched your search
@@ -4744,6 +4744,8 @@ $\mathit{RO}_\mathit{run}$ & {\tt API\_version/vendor\_implementation} & (strin
|
||||
$\mathit{RO}_\mathit{run}$ & {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
|
||||
$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
|
||||
$\mathit{RO}_\mathit{run}$ & {\tt capabilities} & string Set & Xen capabilities \\
|
||||
$\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'' \\
|
||||
$\mathit{RO}_\mathit{run}$ & {\tt sched\_policy} & string & Scheduler policy currently in force on this host \\
|
||||
$\mathit{RO}_\mathit{run}$ & {\tt supported\_bootloaders} & string Set & a list of the bootloaders installed on the machine \\
|
||||
$\mathit{RO}_\mathit{run}$ & {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\
|
||||
$\mathit{RW}$ & {\tt logging} & (string $\rightarrow$ string) Map & logging configuration \\
|
||||
@@ -5548,6 +5550,70 @@ string Set
|
||||
}
|
||||
|
||||
|
||||
value of the field
|
||||
\vspace{0.3cm}
|
||||
\vspace{0.3cm}
|
||||
\vspace{0.3cm}
|
||||
\subsubsection{RPC name:~get\_cpu\_configuration}
|
||||
|
||||
{\bf Overview:}
|
||||
Get the cpu\_configuration field of the given host.
|
||||
|
||||
\noindent {\bf Signature:}
|
||||
\begin{verbatim} ((string -> string) Map) get_cpu_configuration (session_id s, host ref self)\end{verbatim}
|
||||
|
||||
|
||||
\noindent{\bf Arguments:}
|
||||
|
||||
|
||||
\vspace{0.3cm}
|
||||
\begin{tabular}{|c|c|p{7cm}|}
|
||||
\hline
|
||||
{\bf type} & {\bf name} & {\bf description} \\ \hline
|
||||
{\tt host ref } & self & reference to the object \\ \hline
|
||||
|
||||
\end{tabular}
|
||||
|
||||
\vspace{0.3cm}
|
||||
|
||||
\noindent {\bf Return Type:}
|
||||
{\tt
|
||||
(string $\rightarrow$ string) Map
|
||||
}
|
||||
|
||||
|
||||
value of the field
|
||||
\vspace{0.3cm}
|
||||
\vspace{0.3cm}
|
||||
\vspace{0.3cm}
|
||||
\subsubsection{RPC name:~get\_sched\_policy}
|
||||
|
||||
{\bf Overview:}
|
||||
Get the sched\_policy field of the given host.
|
||||
|
||||
\noindent {\bf Signature:}
|
||||
\begin{verbatim} string get_sched_policy (session_id s, host ref self)\end{verbatim}
|
||||
|
||||
|
||||
\noindent{\bf Arguments:}
|
||||
|
||||
|
||||
\vspace{0.3cm}
|
||||
\begin{tabular}{|c|c|p{7cm}|}
|
||||
\hline
|
||||
{\bf type} & {\bf name} & {\bf description} \\ \hline
|
||||
{\tt host ref } & self & reference to the object \\ \hline
|
||||
|
||||
\end{tabular}
|
||||
|
||||
\vspace{0.3cm}
|
||||
|
||||
\noindent {\bf Return Type:}
|
||||
{\tt
|
||||
string
|
||||
}
|
||||
|
||||
|
||||
value of the field
|
||||
\vspace{0.3cm}
|
||||
\vspace{0.3cm}
|
||||
|
||||
@@ -79,6 +79,8 @@ typedef struct xen_host_record
|
||||
xen_string_string_map *software_version;
|
||||
xen_string_string_map *other_config;
|
||||
struct xen_string_set *capabilities;
|
||||
xen_string_string_map *cpu_configuration;
|
||||
char *sched_policy;
|
||||
struct xen_string_set *supported_bootloaders;
|
||||
struct xen_vm_record_opt_set *resident_vms;
|
||||
xen_string_string_map *logging;
|
||||
@@ -260,6 +262,20 @@ extern bool
|
||||
xen_host_get_capabilities(xen_session *session, struct xen_string_set **result, xen_host host);
|
||||
|
||||
|
||||
/**
|
||||
* Get the cpu_configuration field of the given host.
|
||||
*/
|
||||
extern bool
|
||||
xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host);
|
||||
|
||||
|
||||
/**
|
||||
* Get the sched_policy field of the given host.
|
||||
*/
|
||||
extern bool
|
||||
xen_host_get_sched_policy(xen_session *session, char **result, xen_host host);
|
||||
|
||||
|
||||
/**
|
||||
* Get the supported_bootloaders field of the given host.
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,12 @@ static const struct_member xen_host_record_struct_members[] =
|
||||
{ .key = "capabilities",
|
||||
.type = &abstract_type_string_set,
|
||||
.offset = offsetof(xen_host_record, capabilities) },
|
||||
{ .key = "cpu_configuration",
|
||||
.type = &abstract_type_string_string_map,
|
||||
.offset = offsetof(xen_host_record, cpu_configuration) },
|
||||
{ .key = "sched_policy",
|
||||
.type = &abstract_type_string,
|
||||
.offset = offsetof(xen_host_record, sched_policy) },
|
||||
{ .key = "supported_bootloaders",
|
||||
.type = &abstract_type_string_set,
|
||||
.offset = offsetof(xen_host_record, supported_bootloaders) },
|
||||
@@ -128,6 +134,8 @@ xen_host_record_free(xen_host_record *record)
|
||||
xen_string_string_map_free(record->software_version);
|
||||
xen_string_string_map_free(record->other_config);
|
||||
xen_string_set_free(record->capabilities);
|
||||
xen_string_string_map_free(record->cpu_configuration);
|
||||
free(record->sched_policy);
|
||||
xen_string_set_free(record->supported_bootloaders);
|
||||
xen_vm_record_opt_set_free(record->resident_vms);
|
||||
xen_string_string_map_free(record->logging);
|
||||
@@ -349,6 +357,40 @@ xen_host_get_capabilities(xen_session *session, struct xen_string_set **result,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host)
|
||||
{
|
||||
abstract_value param_values[] =
|
||||
{
|
||||
{ .type = &abstract_type_string,
|
||||
.u.string_val = host }
|
||||
};
|
||||
|
||||
abstract_type result_type = abstract_type_string_string_map;
|
||||
|
||||
*result = NULL;
|
||||
XEN_CALL_("host.get_cpu_configuration");
|
||||
return session->ok;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
xen_host_get_sched_policy(xen_session *session, char **result, xen_host host)
|
||||
{
|
||||
abstract_value param_values[] =
|
||||
{
|
||||
{ .type = &abstract_type_string,
|
||||
.u.string_val = host }
|
||||
};
|
||||
|
||||
abstract_type result_type = abstract_type_string;
|
||||
|
||||
*result = NULL;
|
||||
XEN_CALL_("host.get_sched_policy");
|
||||
return session->ok;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host)
|
||||
{
|
||||
|
||||
@@ -285,6 +285,40 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
xen_string_string_map *cpu_configuration;
|
||||
if (!xen_host_get_cpu_configuration(session, &cpu_configuration, host))
|
||||
{
|
||||
print_error(session);
|
||||
free(dmesg);
|
||||
xen_string_set_free(capabilities);
|
||||
xen_string_set_free(supported_bootloaders);
|
||||
xen_string_string_map_free(versions);
|
||||
xen_host_free(host);
|
||||
xen_vm_record_free(vm_record);
|
||||
xen_uuid_bytes_free(vm_uuid_bytes);
|
||||
xen_uuid_free(vm_uuid);
|
||||
xen_vm_free(vm);
|
||||
CLEANUP;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *sched_policy;
|
||||
if (!xen_host_get_sched_policy(session, &sched_policy, host))
|
||||
{
|
||||
print_error(session);
|
||||
xen_string_string_map_free(cpu_configuration);
|
||||
xen_string_set_free(capabilities);
|
||||
xen_string_set_free(supported_bootloaders);
|
||||
xen_string_string_map_free(versions);
|
||||
xen_host_free(host);
|
||||
xen_vm_record_free(vm_record);
|
||||
xen_uuid_bytes_free(vm_uuid_bytes);
|
||||
xen_uuid_free(vm_uuid);
|
||||
xen_vm_free(vm);
|
||||
CLEANUP;
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s.\n", vm_uuid);
|
||||
|
||||
printf("In bytes, the VM UUID is ");
|
||||
@@ -318,6 +352,15 @@ int main(int argc, char **argv)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("Host has the following CPU configuration:\n");
|
||||
for (size_t i = 0; i < cpu_configuration->size; i++)
|
||||
{
|
||||
printf(" %s -> %s.\n", cpu_configuration->contents[i].key,
|
||||
cpu_configuration->contents[i].val);
|
||||
}
|
||||
|
||||
printf("Current scheduler policy: %s.\n\n", sched_policy);
|
||||
|
||||
printf("%s.\n", vm_record->uuid);
|
||||
|
||||
printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle);
|
||||
@@ -334,6 +377,8 @@ int main(int argc, char **argv)
|
||||
free(dmesg);
|
||||
xen_string_set_free(supported_bootloaders);
|
||||
xen_string_set_free(capabilities);
|
||||
xen_string_string_map_free(cpu_configuration);
|
||||
free(sched_policy);
|
||||
|
||||
print_vm_metrics(session, vm);
|
||||
if (!session->ok)
|
||||
|
||||
@@ -860,13 +860,13 @@ class XendAPI(object):
|
||||
'metrics',
|
||||
'capabilities',
|
||||
'supported_bootloaders',
|
||||
'sched_policy',
|
||||
'API_version_major',
|
||||
'API_version_minor',
|
||||
'API_version_vendor',
|
||||
'API_version_vendor_implementation']
|
||||
|
||||
host_attr_rw = ['name_label',
|
||||
'sched_policy',
|
||||
'name_description',
|
||||
'other_config']
|
||||
|
||||
|
||||