Skip to content

Commit

Permalink
xen/arm: compile and run libxl/xl
Browse files Browse the repository at this point in the history
Move tsc, rtc, memmap_limit, localtime and shadow settings from
libxl__build_pre to libxl__arch_domain_create.

Get the console and xenstore pfn's from struct xc_dom_image for
autotranslated guests.

Signed-off-by: Stefano Stabellini <[email protected]>
Acked-by: Ian Campbell <[email protected]>
Committed-by: Ian Campbell <[email protected]>
  • Loading branch information
Stefano Stabellini committed Feb 15, 2013
1 parent c967d12 commit e6b5f70
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 47 deletions.
54 changes: 7 additions & 47 deletions tools/libxl/libxl_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *info, libxl__domain_build_state *state)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
int tsc_mode;
char *xs_domid, *con_domid;
uint32_t rtc_timeoffset;

xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus);

Expand Down Expand Up @@ -233,49 +231,6 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus, &info->cpumap);

xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
if (info->type == LIBXL_DOMAIN_TYPE_PV)
xc_domain_set_memmap_limit(ctx->xch, domid,
(info->max_memkb + info->u.pv.slack_memkb));
switch (info->tsc_mode) {
case LIBXL_TSC_MODE_DEFAULT:
tsc_mode = 0;
break;
case LIBXL_TSC_MODE_ALWAYS_EMULATE:
tsc_mode = 1;
break;
case LIBXL_TSC_MODE_NATIVE:
tsc_mode = 2;
break;
case LIBXL_TSC_MODE_NATIVE_PARAVIRT:
tsc_mode = 3;
break;
default:
abort();
}
xc_domain_set_tsc_info(ctx->xch, domid, tsc_mode, 0, 0, 0);
if (libxl_defbool_val(info->disable_migrate))
xc_domain_disable_migrate(ctx->xch, domid);

rtc_timeoffset = info->rtc_timeoffset;
if (libxl_defbool_val(info->localtime)) {
time_t t;
struct tm *tm;

t = time(NULL);
tm = localtime(&t);

rtc_timeoffset += tm->tm_gmtoff;
}

if (rtc_timeoffset)
xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset);

if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
unsigned long shadow;
shadow = (info->shadow_memkb + 1023) / 1024;
xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
}

xs_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenstored/domid", NULL);
state->store_domid = xs_domid ? atoi(xs_domid) : 0;
free(xs_domid);
Expand Down Expand Up @@ -442,8 +397,13 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
goto out;
}

state->console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
state->store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
if (xc_dom_feature_translated(dom)) {
state->console_mfn = dom->console_pfn;
state->store_mfn = dom->xenstore_pfn;
} else {
state->console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
state->store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn);
}

libxl__file_reference_unmap(&state->pv_kernel);
libxl__file_reference_unmap(&state->pv_ramdisk);
Expand Down
48 changes: 48 additions & 0 deletions tools/libxl/libxl_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,54 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
uint32_t domid)
{
int ret = 0;
int tsc_mode;
uint32_t rtc_timeoffset;
libxl_ctx *ctx = libxl__gc_owner(gc);

if (d_config->b_info.type == LIBXL_DOMAIN_TYPE_PV)
xc_domain_set_memmap_limit(ctx->xch, domid,
(d_config->b_info.max_memkb +
d_config->b_info.u.pv.slack_memkb));

switch (d_config->b_info.tsc_mode) {
case LIBXL_TSC_MODE_DEFAULT:
tsc_mode = 0;
break;
case LIBXL_TSC_MODE_ALWAYS_EMULATE:
tsc_mode = 1;
break;
case LIBXL_TSC_MODE_NATIVE:
tsc_mode = 2;
break;
case LIBXL_TSC_MODE_NATIVE_PARAVIRT:
tsc_mode = 3;
break;
default:
abort();
}
xc_domain_set_tsc_info(ctx->xch, domid, tsc_mode, 0, 0, 0);
if (libxl_defbool_val(d_config->b_info.disable_migrate))
xc_domain_disable_migrate(ctx->xch, domid);
rtc_timeoffset = d_config->b_info.rtc_timeoffset;
if (libxl_defbool_val(d_config->b_info.localtime)) {
time_t t;
struct tm *tm;

t = time(NULL);
tm = localtime(&t);

rtc_timeoffset += tm->tm_gmtoff;
}

if (rtc_timeoffset)
xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset);

if (d_config->b_info.type == LIBXL_DOMAIN_TYPE_HVM) {
unsigned long shadow;
shadow = (d_config->b_info.shadow_memkb + 1023) / 1024;
xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
}

if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
libxl_defbool_val(d_config->b_info.u.pv.e820_host)) {
ret = libxl__e820_alloc(gc, domid, d_config);
Expand Down

0 comments on commit e6b5f70

Please sign in to comment.