diff mbox series

[Xen-devel,for-4.11] libxl: arm: Fix build after c/s 74fd984ae

Message ID 20180410112453.16252-1-julien.grall@arm.com
State Accepted
Commit 50f8ba84a50ebf80dd22067a04062dbaaf2621ff
Headers show
Series [Xen-devel,for-4.11] libxl: arm: Fix build after c/s 74fd984ae | expand

Commit Message

Julien Grall April 10, 2018, 11:24 a.m. UTC
c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from
libxl__domain_build_state" removed state->config completely but missed
some conversion libxl_arm.c.

Furthermore, not all the fields of xc_domain_configuration_t have a
corresponding field in libxl_domain_build_info. This is the case of
clock_frequency. As the field should not be exposed to the user, add a
corresponding field in libxl__domain_build_state. This require some
modification in the prototype of libxl__domain_make in order to have the
state.

For all the other fields, use the up-to-date version in
libxl_domain_build-info.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 tools/libxl/libxl_arch.h     |  1 +
 tools/libxl/libxl_arm.c      | 25 +++++++++++++------------
 tools/libxl/libxl_create.c   |  5 +++--
 tools/libxl/libxl_dm.c       |  3 ++-
 tools/libxl/libxl_internal.h |  4 ++++
 tools/libxl/libxl_x86.c      |  1 +
 6 files changed, 24 insertions(+), 15 deletions(-)

Comments

Wei Liu April 10, 2018, 11:45 a.m. UTC | #1
On Tue, Apr 10, 2018 at 12:24:53PM +0100, Julien Grall wrote:
> c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from
> libxl__domain_build_state" removed state->config completely but missed
> some conversion libxl_arm.c.
> 
> Furthermore, not all the fields of xc_domain_configuration_t have a
> corresponding field in libxl_domain_build_info. This is the case of
> clock_frequency. As the field should not be exposed to the user, add a
> corresponding field in libxl__domain_build_state. This require some
> modification in the prototype of libxl__domain_make in order to have the
> state.
> 
> For all the other fields, use the up-to-date version in
> libxl_domain_build-info.

Typo here.

> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>
Juergen Gross April 10, 2018, 12:03 p.m. UTC | #2
On 10/04/18 13:24, Julien Grall wrote:
> c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from
> libxl__domain_build_state" removed state->config completely but missed
> some conversion libxl_arm.c.
> 
> Furthermore, not all the fields of xc_domain_configuration_t have a
> corresponding field in libxl_domain_build_info. This is the case of
> clock_frequency. As the field should not be exposed to the user, add a
> corresponding field in libxl__domain_build_state. This require some
> modification in the prototype of libxl__domain_make in order to have the
> state.
> 
> For all the other fields, use the up-to-date version in
> libxl_domain_build-info.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index e3b6f5f41a..318c111bb4 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -25,6 +25,7 @@  int libxl__arch_domain_prepare_config(libxl__gc *gc,
 _hidden
 int libxl__arch_domain_save_config(libxl__gc *gc,
                                    libxl_domain_config *d_config,
+                                   libxl__domain_build_state *state,
                                    const xc_domain_configuration_t *xc_config);
 
 /* arch specific internal domain creation function */
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index fbe8786a8e..8af9f6f992 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -25,12 +25,12 @@ 
 #define DT_IRQ_TYPE_LEVEL_HIGH     0x00000004
 #define DT_IRQ_TYPE_LEVEL_LOW      0x00000008
 
-static const char *gicv_to_string(uint8_t gic_version)
+static const char *gicv_to_string(libxl_gic_version gic_version)
 {
     switch (gic_version) {
-    case XEN_DOMCTL_CONFIG_GIC_V2:
+    case LIBXL_GIC_VERSION_V2:
         return "V2";
-    case XEN_DOMCTL_CONFIG_GIC_V3:
+    case LIBXL_GIC_VERSION_V3:
         return "V3";
     default:
         return "unknown";
@@ -110,6 +110,7 @@  int libxl__arch_domain_prepare_config(libxl__gc *gc,
 
 int libxl__arch_domain_save_config(libxl__gc *gc,
                                    libxl_domain_config *d_config,
+                                   libxl__domain_build_state *state,
                                    const xc_domain_configuration_t *xc_config)
 {
     switch (xc_config->gic_version) {
@@ -124,6 +125,8 @@  int libxl__arch_domain_save_config(libxl__gc *gc,
         return ERROR_FAIL;
     }
 
+    state->clock_frequency = xc_config->clock_frequency;
+
     return 0;
 }
 
@@ -846,9 +849,6 @@  static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
     const libxl_version_info *vers;
     const struct arch_info *ainfo;
 
-    /* convenience aliases */
-    xc_domain_configuration_t *xc_config = &state->config;
-
     vers = libxl_get_version_info(CTX);
     if (vers == NULL) return ERROR_FAIL;
 
@@ -857,7 +857,8 @@  static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_build_info *info,
 
     LOG(DEBUG, "constructing DTB for Xen version %d.%d guest",
         vers->xen_version_major, vers->xen_version_minor);
-    LOG(DEBUG, " - vGIC version: %s", gicv_to_string(xc_config->gic_version));
+    LOG(DEBUG, " - vGIC version: %s",
+        gicv_to_string(info->arch_arm.gic_version));
 
     if (info->device_tree) {
         LOG(DEBUG, " - Partial device tree provided: %s", info->device_tree);
@@ -922,23 +923,23 @@  next_resize:
 
         FDT( make_memory_nodes(gc, fdt, dom) );
 
-        switch (xc_config->gic_version) {
-        case XEN_DOMCTL_CONFIG_GIC_V2:
+        switch (info->arch_arm.gic_version) {
+        case LIBXL_GIC_VERSION_V2:
             FDT( make_gicv2_node(gc, fdt,
                                  GUEST_GICD_BASE, GUEST_GICD_SIZE,
                                  GUEST_GICC_BASE, GUEST_GICC_SIZE) );
             break;
-        case XEN_DOMCTL_CONFIG_GIC_V3:
+        case LIBXL_GIC_VERSION_V3:
             FDT( make_gicv3_node(gc, fdt) );
             break;
         default:
             LOG(ERROR, "Unknown GIC version %s",
-                gicv_to_string(xc_config->gic_version));
+                gicv_to_string(info->arch_arm.gic_version));
             rc = ERROR_FAIL;
             goto out;
         }
 
-        FDT( make_timer_node(gc, fdt, ainfo, xc_config->clock_frequency) );
+        FDT( make_timer_node(gc, fdt, ainfo, state->clock_frequency) );
         FDT( make_hypervisor_node(gc, fdt, vers) );
 
         if (info->arch_arm.vuart == LIBXL_VUART_TYPE_SBSA_UART)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 692461a5a1..b5e27a7766 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -538,6 +538,7 @@  out:
 }
 
 int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
+                       libxl__domain_build_state *state,
                        uint32_t *domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -590,7 +591,7 @@  int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
             goto out;
         }
 
-        rc = libxl__arch_domain_save_config(gc, d_config, &xc_config);
+        rc = libxl__arch_domain_save_config(gc, d_config, state, &xc_config);
         if (rc < 0)
             goto out;
     }
@@ -958,7 +959,7 @@  static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
-    ret = libxl__domain_make(gc, d_config, &domid);
+    ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid);
     if (ret) {
         LOGD(ERROR, domid, "cannot make domain: %d", ret);
         dcs->guest_domid = domid;
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 7f795a4ffd..b662395b2e 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1960,7 +1960,8 @@  void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
     stubdom_state->pv_ramdisk.path = "";
 
     /* fixme: this function can leak the stubdom if it fails */
-    ret = libxl__domain_make(gc, dm_config, &sdss->pvqemu.guest_domid);
+    ret = libxl__domain_make(gc, dm_config, stubdom_state,
+                             &sdss->pvqemu.guest_domid);
     if (ret)
         goto out;
     uint32_t dm_domid = sdss->pvqemu.guest_domid;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 584410d705..6352380644 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1147,6 +1147,9 @@  typedef struct {
 
     xen_pfn_t vuart_gfn;
     evtchn_port_t vuart_port;
+
+    /* ARM only to deal with broken firmware */
+    uint32_t clock_frequency;
 } libxl__domain_build_state;
 
 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid,
@@ -1655,6 +1658,7 @@  _hidden  void libxl__exec(libxl__gc *gc, int stdinfd, int stdoutfd,
   * on exit (even error exit), domid may be valid and refer to a domain */
 _hidden int libxl__domain_make(libxl__gc *gc,
                                libxl_domain_config *d_config,
+                               libxl__domain_build_state *state,
                                uint32_t *domid);
 
 _hidden int libxl__domain_build(libxl__gc *gc,
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 78affdd37a..4573d6764d 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -26,6 +26,7 @@  int libxl__arch_domain_prepare_config(libxl__gc *gc,
 
 int libxl__arch_domain_save_config(libxl__gc *gc,
                                    libxl_domain_config *d_config,
+                                   libxl__domain_build_state *state,
                                    const xc_domain_configuration_t *xc_config)
 {
     return 0;