@@ -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 */
@@ -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)
@@ -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;
@@ -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;
@@ -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,
@@ -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;
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(-)