# HG changeset patch
# User Andre Przywara <andre.przywara@xxxxxxx>
# Date 1284656560 -3600
# Node ID 4e47a7db9711818048ea2dd0d111286e8bcf1249
# Parent ea47cb5d5755ee18e432db2ba603fc2e64f7e086
libxl: introduce cpuid interface to domain build
Add a cpuid parameter into libxl_domain_build_info and use
it's content while setting up the domain. This is a only paving the way,
the real functionality is implemented in the later patches.
Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
tools/libxl/libxl.c | 15 +++++++++++++++
tools/libxl/libxl.h | 8 ++++++++
tools/libxl/libxl.idl | 2 ++
tools/libxl/libxl_dom.c | 6 ++++++
tools/libxl/libxl_internal.h | 11 +++++++++++
tools/libxl/xl_cmdimpl.c | 1 +
6 files changed, 43 insertions(+)
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/libxl.c Thu Sep 16 18:02:40 2010 +0100
@@ -100,6 +100,21 @@ void libxl_key_value_list_destroy(libxl_
free(kvl[i + 1]);
}
free(kvl);
+}
+
+void libxl_cpuid_destroy(libxl_cpuid_policy_list *p_cpuid_list)
+{
+ int i, j;
+ libxl_cpuid_policy_list cpuid_list = *p_cpuid_list;
+
+ if (cpuid_list == NULL)
+ return;
+ for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
+ for (j = 0; j < 4; j++)
+ if (cpuid_list[i].policy[j] != NULL)
+ free(cpuid_list[i].policy[j]);
+ }
+ return;
}
/******************************************************************************/
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/libxl.h Thu Sep 16 18:02:40 2010 +0100
@@ -185,6 +185,14 @@ typedef struct {
size_t size;
} libxl_file_reference;
void libxl_file_reference_destroy(libxl_file_reference *p);
+
+/* libxl_cpuid_policy_list is a dynamic array storing CPUID policies
+ * for multiple leafs. It is terminated with an entry holding
+ * XEN_CPUID_INPUT_UNUSED in input[0]
+ */
+typedef struct libxl__cpuid_policy libxl_cpuid_policy;
+typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
+void libxl_cpuid_destroy(libxl_cpuid_policy_list *cpuid_list);
#define LIBXL_PCI_FUNC_ALL (~0U)
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/libxl.idl Thu Sep 16 18:02:40 2010 +0100
@@ -11,6 +11,7 @@ libxl_console_constype = Number("console
libxl_console_constype = Number("console_constype", namespace="libxl_")
libxl_disk_phystype = Number("disk_phystype", namespace="libxl_")
libxl_nic_type = Number("nic_type", namespace="libxl_")
+libxl_cpuid_policy_list = Builtin("cpuid_policy_list",
destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE)
libxl_string_list = Builtin("string_list",
destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
libxl_key_value_list = Builtin("key_value_list",
destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE)
@@ -90,6 +91,7 @@ libxl_domain_build_info = Struct("domain
("shadow_memkb", uint32),
("disable_migrate", bool),
("kernel", libxl_file_reference),
+ ("cpuid", libxl_cpuid_policy_list),
("hvm", integer),
("u", KeyedUnion(None, "hvm",
[("hvm", "%s", Struct(None,
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/libxl_dom.c Thu Sep 16 18:02:40 2010 +0100
@@ -95,9 +95,15 @@ int libxl__build_post(libxl_ctx *ctx, ui
xs_transaction_t t;
char **ents;
int i;
+ char *cpuid_res[4];
#if defined(__i386__) || defined(__x86_64__)
xc_cpuid_apply_policy(ctx->xch, domid);
+ if (info->cpuid != NULL) {
+ for (i = 0; info->cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++)
+ xc_cpuid_set(ctx->xch, domid, info->cpuid[i].input,
+ (const char**)(info->cpuid[i].policy), cpuid_res);
+ }
#endif
ents = libxl__calloc(&gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/libxl_internal.h Thu Sep 16 18:02:40 2010 +0100
@@ -236,6 +236,17 @@ _hidden char *libxl__domid_to_name(libxl
_hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid);
_hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid);
+
+ /* holds the CPUID response for a single CPUID leaf
+ * input contains the value of the EAX and ECX register,
+ * and each policy string contains a filter to apply to
+ * the host given values for that particular leaf.
+ */
+struct libxl__cpuid_policy {
+ uint32_t input[2];
+ char *policy[4];
+};
+
/*
* blktap2 support
*/
diff -r ea47cb5d5755 -r 4e47a7db9711 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Thu Sep 16 17:49:43 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Thu Sep 16 18:02:40 2010 +0100
@@ -271,6 +271,7 @@ static void init_build_info(libxl_domain
b_info->max_memkb = 32 * 1024;
b_info->target_memkb = b_info->max_memkb;
b_info->disable_migrate = 0;
+ b_info->cpuid = NULL;
if (c_info->hvm) {
b_info->shadow_memkb = 0; /* Set later */
b_info->video_memkb = 8 * 1024;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|