[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: specify HVM vs PV in build_info using libxl_domain_type enum
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1310997150 -3600 # Node ID 30ab13a761c11dac58a4f8fb2ebf3d6f40b9c362 # Parent 97cb910d39b303005936f321eb93efbbd03e7c4c libxl: specify HVM vs PV in build_info using libxl_domain_type enum Also caught one place (in libxl__domain_restore_common) which used info->u.hvm.pae even if !hvm. (fortunately the value was unused in xc_domain_restore). Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> --- diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl.c Mon Jul 18 14:52:30 2011 +0100 @@ -2036,17 +2036,27 @@ libxl_device_model_info *dm_info, uint32_t *need_memkb) { libxl__gc gc = LIBXL_INIT_GC(ctx); + int rc = ERROR_INVAL; *need_memkb = b_info->target_memkb; - if (b_info->hvm) { + switch (b_info->type) { + case LIBXL_DOMAIN_TYPE_HVM: *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY; if (dm_info->device_model_stubdomain) *need_memkb += 32 * 1024; - } else + break; + case LIBXL_DOMAIN_TYPE_PV: *need_memkb += b_info->shadow_memkb + LIBXL_PV_EXTRA_MEMORY; + break; + default: + goto out; + } if (*need_memkb % (2 * 1024)) *need_memkb += (2 * 1024) - (*need_memkb % (2 * 1024)); + rc = 0; +out: libxl__free_all(&gc); - return 0; + return rc; + } int libxl_get_free_memory(libxl_ctx *ctx, uint32_t *memkb) diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl.idl Mon Jul 18 14:52:30 2011 +0100 @@ -158,9 +158,9 @@ ("shadow_memkb", uint32), ("disable_migrate", bool), ("cpuid", libxl_cpuid_policy_list), - ("hvm", bool), - ("u", KeyedUnion(None, "hvm", - [("hvm", "%s", Struct(None, + ("type", libxl_domain_type), + ("u", KeyedUnion(None, "type", + [("hvm", "%s == LIBXL_DOMAIN_TYPE_HVM", Struct(None, [("firmware", string), ("pae", bool), ("apic", bool), @@ -173,7 +173,7 @@ ("timer_mode", integer), ("nested_hvm", bool), ])), - ("pv", "!%s", Struct(None, + ("pv", "%s == LIBXL_DOMAIN_TYPE_PV", Struct(None, [("kernel", libxl_file_reference), ("slack_memkb", uint32), ("bootloader", string), diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl_bootloader.c Mon Jul 18 14:52:30 2011 +0100 @@ -323,7 +323,7 @@ struct stat st_buf; - if (info->hvm || !info->u.pv.bootloader) + if (info->type != LIBXL_DOMAIN_TYPE_PV || !info->u.pv.bootloader) goto out; rc = ERROR_INVAL; diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl_create.c Mon Jul 18 14:52:30 2011 +0100 @@ -84,7 +84,7 @@ b_info->shadow_memkb = 0; if (c_info->hvm) { b_info->video_memkb = 8 * 1024; - b_info->hvm = 1; + b_info->type = LIBXL_DOMAIN_TYPE_HVM; b_info->u.hvm.firmware = NULL; b_info->u.hvm.pae = 1; b_info->u.hvm.apic = 1; @@ -96,6 +96,7 @@ b_info->u.hvm.timer_mode = 1; b_info->u.hvm.nested_hvm = 0; } else { + b_info->type = LIBXL_DOMAIN_TYPE_PV; b_info->u.pv.slack_memkb = 8 * 1024; } } @@ -160,7 +161,8 @@ gettimeofday(&start_time, NULL); - if (info->hvm) { + switch (info->type) { + case LIBXL_DOMAIN_TYPE_HVM: ret = libxl__build_hvm(gc, domid, info, dm_info, state); if (ret) goto out; @@ -172,7 +174,8 @@ vments[3] = "hvm"; vments[4] = "start_time"; vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); - } else { + break; + case LIBXL_DOMAIN_TYPE_PV: ret = libxl__build_pv(gc, domid, info, state); if (ret) goto out; @@ -193,6 +196,10 @@ vments[i++] = "image/cmdline"; vments[i++] = (char*) info->u.pv.cmdline; } + break; + default: + ret = ERROR_INVAL; + goto out; } ret = libxl__build_post(gc, domid, info, state, vments, localents); out: @@ -219,7 +226,8 @@ gettimeofday(&start_time, NULL); - if (info->hvm) { + switch (info->type) { + case LIBXL_DOMAIN_TYPE_HVM: vments = libxl__calloc(gc, 7, sizeof(char *)); vments[0] = "rtc/timeoffset"; vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : ""; @@ -227,7 +235,8 @@ vments[3] = "hvm"; vments[4] = "start_time"; vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); - } else { + break; + case LIBXL_DOMAIN_TYPE_PV: vments = libxl__calloc(gc, 11, sizeof(char *)); i = 0; vments[i++] = "image/ostype"; @@ -244,20 +253,24 @@ vments[i++] = "image/cmdline"; vments[i++] = (char*) info->u.pv.cmdline; } + break; + default: + ret = ERROR_INVAL; + goto out; } ret = libxl__build_post(gc, domid, info, state, vments, localents); if (ret) goto out; dm_info->saved_state = NULL; - if (info->hvm) { + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { ret = asprintf(&dm_info->saved_state, XC_DEVICE_MODEL_RESTORE_FILE".%d", domid); ret = (ret < 0) ? ERROR_FAIL : 0; } out: - if (!info->hvm) { + if (info->type == LIBXL_DOMAIN_TYPE_PV) { libxl__file_reference_unmap(&info->u.pv.kernel); libxl__file_reference_unmap(&info->u.pv.ramdisk); } diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl_dm.c Mon Jul 18 14:52:30 2011 +0100 @@ -638,12 +638,13 @@ b_info.max_vcpus = 1; b_info.max_memkb = 32 * 1024; b_info.target_memkb = b_info.max_memkb; + + b_info.type = LIBXL_DOMAIN_TYPE_PV; b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path()); b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", info->domid); b_info.u.pv.ramdisk.path = ""; b_info.u.pv.features = ""; - b_info.hvm = 0; /* fixme: this function can leak the stubdom if it fails */ diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/libxl_dom.c Mon Jul 18 14:52:30 2011 +0100 @@ -75,14 +75,14 @@ libxl_ctx *ctx = libxl__gc_owner(gc); xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus); xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT); - if (!info->hvm) + if (info->type == LIBXL_DOMAIN_TYPE_PV) xc_domain_set_memmap_limit(ctx->xch, domid, (info->max_memkb + info->u.pv.slack_memkb)); xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0); if ( info->disable_migrate ) xc_domain_disable_migrate(ctx->xch, domid); - if (info->hvm) { + 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); @@ -340,10 +340,25 @@ libxl_ctx *ctx = libxl__gc_owner(gc); /* read signature */ int rc; + int hvm, pae, superpages; + switch (info->type) { + case LIBXL_DOMAIN_TYPE_HVM: + hvm = 1; + superpages = 1; + pae = info->u.hvm.pae; + break; + case LIBXL_DOMAIN_TYPE_PV: + hvm = 0; + superpages = 0; + pae = 1; + break; + default: + return ERROR_INVAL; + } rc = xc_domain_restore(ctx->xch, fd, domid, - state->store_port, &state->store_mfn, - state->console_port, &state->console_mfn, - info->hvm, info->u.hvm.pae, !!info->hvm); + state->store_port, &state->store_mfn, + state->console_port, &state->console_mfn, + hvm, pae, superpages); if ( rc ) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "restoring domain"); return ERROR_FAIL; diff -r 97cb910d39b3 -r 30ab13a761c1 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jul 18 14:52:30 2011 +0100 +++ b/tools/libxl/xl_cmdimpl.c Mon Jul 18 14:52:30 2011 +0100 @@ -381,7 +381,7 @@ printf("\t\t\t(spiceagent_mouse %d)\n", dm_info->spiceagent_mouse); printf("\t\t)\n"); } else { - printf("\t\t(linux %d)\n", b_info->hvm); + printf("\t\t(linux %d)\n", 0); printf("\t\t\t(kernel %s)\n", b_info->u.pv.kernel.path); printf("\t\t\t(cmdline %s)\n", b_info->u.pv.cmdline); printf("\t\t\t(ramdisk %s)\n", b_info->u.pv.ramdisk.path); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |