debuggers.hg

changeset 22216:4e47a7db9711

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@amd.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Andre Przywara <andre.przywara@amd.com>
date Thu Sep 16 18:02:40 2010 +0100 (2010-09-16)
parents ea47cb5d5755
children d978675f3d53
files tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl.idl tools/libxl/libxl_dom.c tools/libxl/libxl_internal.h tools/libxl/xl_cmdimpl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Thu Sep 16 17:49:43 2010 +0100
     1.2 +++ b/tools/libxl/libxl.c	Thu Sep 16 18:02:40 2010 +0100
     1.3 @@ -102,6 +102,21 @@ void libxl_key_value_list_destroy(libxl_
     1.4      free(kvl);
     1.5  }
     1.6  
     1.7 +void libxl_cpuid_destroy(libxl_cpuid_policy_list *p_cpuid_list)
     1.8 +{
     1.9 +    int i, j;
    1.10 +    libxl_cpuid_policy_list cpuid_list = *p_cpuid_list;
    1.11 +
    1.12 +    if (cpuid_list == NULL)
    1.13 +        return;
    1.14 +    for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
    1.15 +        for (j = 0; j < 4; j++)
    1.16 +            if (cpuid_list[i].policy[j] != NULL)
    1.17 +                free(cpuid_list[i].policy[j]);
    1.18 +    }
    1.19 +    return;
    1.20 +}
    1.21 +
    1.22  /******************************************************************************/
    1.23  
    1.24  int libxl_domain_make(libxl_ctx *ctx, libxl_domain_create_info *info,
     2.1 --- a/tools/libxl/libxl.h	Thu Sep 16 17:49:43 2010 +0100
     2.2 +++ b/tools/libxl/libxl.h	Thu Sep 16 18:02:40 2010 +0100
     2.3 @@ -186,6 +186,14 @@ typedef struct {
     2.4  } libxl_file_reference;
     2.5  void libxl_file_reference_destroy(libxl_file_reference *p);
     2.6  
     2.7 +/* libxl_cpuid_policy_list is a dynamic array storing CPUID policies
     2.8 + * for multiple leafs. It is terminated with an entry holding
     2.9 + * XEN_CPUID_INPUT_UNUSED in input[0]
    2.10 + */
    2.11 +typedef struct libxl__cpuid_policy libxl_cpuid_policy;
    2.12 +typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
    2.13 +void libxl_cpuid_destroy(libxl_cpuid_policy_list *cpuid_list);
    2.14 +
    2.15  #define LIBXL_PCI_FUNC_ALL (~0U)
    2.16  
    2.17  #include "_libxl_types.h"
     3.1 --- a/tools/libxl/libxl.idl	Thu Sep 16 17:49:43 2010 +0100
     3.2 +++ b/tools/libxl/libxl.idl	Thu Sep 16 18:02:40 2010 +0100
     3.3 @@ -11,6 +11,7 @@ libxl_console_consback = Number("console
     3.4  libxl_console_constype = Number("console_constype", namespace="libxl_")
     3.5  libxl_disk_phystype = Number("disk_phystype", namespace="libxl_")
     3.6  libxl_nic_type = Number("nic_type", namespace="libxl_")
     3.7 +libxl_cpuid_policy_list = Builtin("cpuid_policy_list", destructor_fn="libxl_cpuid_destroy", passby=PASS_BY_REFERENCE)
     3.8  
     3.9  libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE)
    3.10  libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE)
    3.11 @@ -90,6 +91,7 @@ libxl_domain_build_info = Struct("domain
    3.12      ("shadow_memkb",    uint32),
    3.13      ("disable_migrate", bool),
    3.14      ("kernel",          libxl_file_reference),
    3.15 +    ("cpuid",           libxl_cpuid_policy_list),
    3.16      ("hvm",             integer),
    3.17      ("u", KeyedUnion(None, "hvm",
    3.18                  [("hvm", "%s", Struct(None,
     4.1 --- a/tools/libxl/libxl_dom.c	Thu Sep 16 17:49:43 2010 +0100
     4.2 +++ b/tools/libxl/libxl_dom.c	Thu Sep 16 18:02:40 2010 +0100
     4.3 @@ -95,9 +95,15 @@ int libxl__build_post(libxl_ctx *ctx, ui
     4.4      xs_transaction_t t;
     4.5      char **ents;
     4.6      int i;
     4.7 +    char *cpuid_res[4];
     4.8  
     4.9  #if defined(__i386__) || defined(__x86_64__)
    4.10      xc_cpuid_apply_policy(ctx->xch, domid);
    4.11 +    if (info->cpuid != NULL) {
    4.12 +        for (i = 0; info->cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++)
    4.13 +            xc_cpuid_set(ctx->xch, domid, info->cpuid[i].input,
    4.14 +                         (const char**)(info->cpuid[i].policy), cpuid_res);
    4.15 +    }
    4.16  #endif
    4.17  
    4.18      ents = libxl__calloc(&gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
     5.1 --- a/tools/libxl/libxl_internal.h	Thu Sep 16 17:49:43 2010 +0100
     5.2 +++ b/tools/libxl/libxl_internal.h	Thu Sep 16 18:02:40 2010 +0100
     5.3 @@ -236,6 +236,17 @@ struct libxl__device_model_starting {
     5.4  _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid);
     5.5  _hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid);
     5.6  
     5.7 +
     5.8 +  /* holds the CPUID response for a single CPUID leaf
     5.9 +   * input contains the value of the EAX and ECX register,
    5.10 +   * and each policy string contains a filter to apply to
    5.11 +   * the host given values for that particular leaf.
    5.12 +   */
    5.13 +struct libxl__cpuid_policy {
    5.14 +    uint32_t input[2];
    5.15 +    char *policy[4];
    5.16 +};
    5.17 +
    5.18  /*
    5.19   * blktap2 support
    5.20   */
     6.1 --- a/tools/libxl/xl_cmdimpl.c	Thu Sep 16 17:49:43 2010 +0100
     6.2 +++ b/tools/libxl/xl_cmdimpl.c	Thu Sep 16 18:02:40 2010 +0100
     6.3 @@ -271,6 +271,7 @@ static void init_build_info(libxl_domain
     6.4      b_info->max_memkb = 32 * 1024;
     6.5      b_info->target_memkb = b_info->max_memkb;
     6.6      b_info->disable_migrate = 0;
     6.7 +    b_info->cpuid = NULL;
     6.8      if (c_info->hvm) {
     6.9          b_info->shadow_memkb = 0; /* Set later */
    6.10          b_info->video_memkb = 8 * 1024;