aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-04-09 12:20:35 +0100
committerEwan Mellor <ewan@xensource.com>2007-04-09 12:20:35 +0100
commit668fbded84ff31d548ae5e84419b2acab88600e2 (patch)
tree372b988fb595c8a0e16f4922e06e28c0467a015a /tools/libxen
parent1a2d0aa9027d6023f3240abd23e0027a2ce25925 (diff)
downloadxen-668fbded84ff31d548ae5e84419b2acab88600e2.tar.gz
xen-668fbded84ff31d548ae5e84419b2acab88600e2.tar.bz2
xen-668fbded84ff31d548ae5e84419b2acab88600e2.zip
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>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_host.h16
-rw-r--r--tools/libxen/src/xen_host.c42
-rw-r--r--tools/libxen/test/test_bindings.c45
3 files changed, 103 insertions, 0 deletions
diff --git a/tools/libxen/include/xen_host.h b/tools/libxen/include/xen_host.h
index f380f989d0..181aa5e22d 100644
--- a/tools/libxen/include/xen_host.h
+++ b/tools/libxen/include/xen_host.h
@@ -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;
@@ -261,6 +263,20 @@ xen_host_get_capabilities(xen_session *session, struct xen_string_set **result,
/**
+ * 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.
*/
extern bool
diff --git a/tools/libxen/src/xen_host.c b/tools/libxen/src/xen_host.c
index a55b91e0af..bc2b1f0e8b 100644
--- a/tools/libxen/src/xen_host.c
+++ b/tools/libxen/src/xen_host.c
@@ -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);
@@ -350,6 +358,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)
{
abstract_value param_values[] =
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index 6da442d539..df067aa438 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -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)