Ross Philipson
2013-Feb-13 21:52 UTC
[PATCH 0 of 3] [v3] HVM firmware passthrough libxl support
This patch series is a follow-up to the earlier HVM firmware passthrough patch set. It introduces support in libxl for specifying and loading the ACPI and SMBIOS firmware blobs that are passed to libxc. There are 3 patches in the series: 01 - Switch xl to use the new xc_hvm_build() libxc API. 02 - Xen xl toolstack changes to load ACPI and SMBIOS firmware files. Doc changes to the man page for xl.cfg describing the new params. 03 - Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c This version cleans up some of the logging and error handling in the new firmware passthrough code. Signed-off-by: Ross Philipson <ross.philipson@citrix.com> (Based on xen-4.3 staging/unstable cs 26527)
Ross Philipson
2013-Feb-13 21:52 UTC
[PATCH 1 of 3] [v3] HVM firmware passthrough libxl support
Switch libxl to use the new xc_hvm_build() libxc API. Signed-off-by: Ross Philipson <ross.philipson@citrix.com> diff -r 63594ce1708f -r c5a851de03f1 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Wed Feb 13 09:31:48 2013 +0100 +++ b/tools/libxl/libxl_dom.c Wed Feb 13 14:51:51 2013 -0500 @@ -542,17 +542,24 @@ int libxl__build_hvm(libxl__gc *gc, uint libxl__domain_build_state *state) { libxl_ctx *ctx = libxl__gc_owner(gc); + struct xc_hvm_build_args args = {}; int ret, rc = ERROR_FAIL; const char *firmware = libxl__domain_firmware(gc, info); if (!firmware) goto out; - ret = xc_hvm_build_target_mem( - ctx->xch, - domid, - (info->max_memkb - info->video_memkb) / 1024, - (info->target_memkb - info->video_memkb) / 1024, - firmware); + + memset(&args, 0, sizeof(struct xc_hvm_build_args)); + /* The params from the configuration file are in Mb, which are then + * multiplied by 1 Kb. This was then divided off when calling + * the old xc_hvm_build_target_mem() which then turned them to bytes. + * Do all this in one step here... + */ + args.mem_size = (uint64_t)(info->max_memkb - info->video_memkb) << 10; + args.mem_target = (uint64_t)(info->target_memkb - info->video_memkb) << 10; + args.image_file_name = firmware; + + ret = xc_hvm_build(ctx->xch, domid, &args); if (ret) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); goto out;
Ross Philipson
2013-Feb-13 21:52 UTC
[PATCH 2 of 3] [v3] HVM firmware passthrough libxl support
This patch introduces support for two new parameters in libxl: smbios_firmware=<path_to_smbios_structures_file> acpi_firmware=<path_to_acpi_tables_file> The changes are primarily in the domain building code where the firmware files are read and passed to libxc for loading into the new guest. After the domain building call to libxc, the addresses for the loaded blobs are returned and written to xenstore. LIBXL_HAVE_FIRMWARE_PASSTHROUGH is defined in libxl.h to allow users to determine if the feature is present. This patch also updates the xl.cfg man page with descriptions of the two new parameters for firmware passthrough. Signed-off-by: Ross Philipson <ross.philipson@citrix.com> diff -r c5a851de03f1 -r 3d809b510886 docs/man/xl.cfg.pod.5 --- a/docs/man/xl.cfg.pod.5 Wed Feb 13 14:51:51 2013 -0500 +++ b/docs/man/xl.cfg.pod.5 Wed Feb 13 16:20:24 2013 -0500 @@ -829,6 +829,25 @@ libxl: ''host,tm=0,sse3=0'' More info about the CPUID instruction can be found in the processor manuals, and in Wikipedia: L<http://en.wikipedia.org/wiki/CPUID> +=item B<acpi_firmware="STRING"> + +Specify a path to a file that contains extra ACPI firmware tables to pass in to +a guest. The file can contain several tables in their binary AML form +concatenated together. Each table self describes its length so no additional +information is needed. These tables will be added to the ACPI table set in the +guest. Note that existing tables cannot be overridden by this feature. For +example this cannot be used to override tables like DSDT, FADT, etc. + +=item B<smbios_firmware="STRING"> + +Specify a path to a file that contains extra SMBIOS firmware structures to pass +in to a guest. The file can contain a set DMTF predefined structures which will +override the internal defaults. Not all predefined structures can be overridden, +only the following types: 0, 1, 2, 3, 11, 22, 39. The file can also contain any +number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS +structures do not present their overall size, each entry in the file must be +preceded by a 32b integer indicating the size of the next structure. + =back =head3 Guest Virtual Time Controls diff -r c5a851de03f1 -r 3d809b510886 tools/libxl/libxl.h --- a/tools/libxl/libxl.h Wed Feb 13 14:51:51 2013 -0500 +++ b/tools/libxl/libxl.h Wed Feb 13 16:20:24 2013 -0500 @@ -68,6 +68,13 @@ */ /* + * LIBXL_HAVE_FIRMWARE_PASSTHROUGH indicates the feature for + * passing in SMBIOS and ACPI firmware to HVM guests is present + * in the library. + */ +#define LIBXL_HAVE_FIRMWARE_PASSTHROUGH 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff -r c5a851de03f1 -r 3d809b510886 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Wed Feb 13 14:51:51 2013 -0500 +++ b/tools/libxl/libxl_dom.c Wed Feb 13 16:20:24 2013 -0500 @@ -21,6 +21,7 @@ #include <xc_dom.h> #include <xen/hvm/hvm_info_table.h> +#include <xen/hvm/hvm_xs_strings.h> libxl_domain_type libxl__domain_type(libxl__gc *gc, uint32_t domid) { @@ -510,11 +511,61 @@ static int hvm_build_set_params(xc_inter return 0; } -static const char *libxl__domain_firmware(libxl__gc *gc, - libxl_domain_build_info *info) +static int hvm_build_set_xs_values(libxl__gc *gc, + uint32_t domid, + struct xc_hvm_build_args *args) +{ + char *path = NULL; + int ret = 0; + + if (args->smbios_module.guest_addr_out) { + path = GCSPRINTF("/local/domain/%d/"HVM_XS_SMBIOS_PT_ADDRESS, domid); + + ret = libxl__xs_write(gc, XBT_NULL, path, "0x%"PRIx64, + args->smbios_module.guest_addr_out); + if (ret) + goto err; + + path = GCSPRINTF("/local/domain/%d/"HVM_XS_SMBIOS_PT_LENGTH, domid); + + ret = libxl__xs_write(gc, XBT_NULL, path, "0x%x", + args->smbios_module.length); + if (ret) + goto err; + } + + if (args->acpi_module.guest_addr_out) { + path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_ADDRESS, domid); + + ret = libxl__xs_write(gc, XBT_NULL, path, "0x%"PRIx64, + args->acpi_module.guest_addr_out); + if (ret) + goto err; + + path = GCSPRINTF("/local/domain/%d/"HVM_XS_ACPI_PT_LENGTH, domid); + + ret = libxl__xs_write(gc, XBT_NULL, path, "0x%x", + args->acpi_module.length); + if (ret) + goto err; + } + + return 0; + +err: + LOG(ERROR, "failed to write firmware xenstore value, err: %d", ret); + return ret; +} + +static int libxl__domain_firmware(libxl__gc *gc, + libxl_domain_build_info *info, + struct xc_hvm_build_args *args) { libxl_ctx *ctx = libxl__gc_owner(gc); const char *firmware; + int e, rc = ERROR_FAIL; + int datalen = 0; + void *data; if (info->u.hvm.firmware) firmware = info->u.hvm.firmware; @@ -528,13 +579,52 @@ static const char *libxl__domain_firmwar firmware = "hvmloader"; break; default: - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "invalid device model version %d", - info->device_model_version); - return NULL; + LOG(ERROR, "invalid device model version %d", + info->device_model_version); + return ERROR_FAIL; break; } } - return libxl__abs_path(gc, firmware, libxl__xenfirmwaredir_path()); + args->image_file_name = libxl__abs_path(gc, firmware, + libxl__xenfirmwaredir_path()); + + if (info->u.hvm.smbios_firmware) { + data = NULL; + e = libxl_read_file_contents(ctx, info->u.hvm.smbios_firmware, + &data, &datalen); + if (e) { + LOGEV(ERROR, e, "failed to read SMBIOS firmware file %s", + info->u.hvm.smbios_firmware); + goto out; + } + libxl__ptr_add(gc, data); + if (datalen) { + /* Only accept non-empty files */ + args->smbios_module.data = data; + args->smbios_module.length = (uint32_t)datalen; + } + } + + if (info->u.hvm.acpi_firmware) { + data = NULL; + e = libxl_read_file_contents(ctx, info->u.hvm.acpi_firmware, + &data, &datalen); + if (e) { + LOGEV(ERROR, e, "failed to read ACPI firmware file %s", + info->u.hvm.acpi_firmware); + goto out; + } + libxl__ptr_add(gc, data); + if (datalen) { + /* Only accept non-empty files */ + args->acpi_module.data = data; + args->acpi_module.length = (uint32_t)datalen; + } + } + + return 0; +out: + return rc; } int libxl__build_hvm(libxl__gc *gc, uint32_t domid, @@ -544,10 +634,6 @@ int libxl__build_hvm(libxl__gc *gc, uint libxl_ctx *ctx = libxl__gc_owner(gc); struct xc_hvm_build_args args = {}; int ret, rc = ERROR_FAIL; - const char *firmware = libxl__domain_firmware(gc, info); - - if (!firmware) - goto out; memset(&args, 0, sizeof(struct xc_hvm_build_args)); /* The params from the configuration file are in Mb, which are then @@ -557,22 +643,34 @@ int libxl__build_hvm(libxl__gc *gc, uint */ args.mem_size = (uint64_t)(info->max_memkb - info->video_memkb) << 10; args.mem_target = (uint64_t)(info->target_memkb - info->video_memkb) << 10; - args.image_file_name = firmware; + + if (libxl__domain_firmware(gc, info, &args)) { + LOG(ERROR, "initializing domain firmware failed"); + goto out; + } ret = xc_hvm_build(ctx->xch, domid, &args); if (ret) { - LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm building failed"); + LOGEV(ERROR, ret, "hvm building failed"); goto out; } + ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port, &state->store_mfn, state->console_port, &state->console_mfn, state->store_domid, state->console_domid); if (ret) { - LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm build set params failed"); + LOGEV(ERROR, ret, "hvm build set params failed"); goto out; } - rc = 0; + + ret = hvm_build_set_xs_values(gc, domid, &args); + if (ret) { + LOG(ERROR, "hvm build set xenstore values failed (ret=%d)", ret); + goto out; + } + + return 0; out: return rc; } @@ -634,7 +732,7 @@ int libxl__toolstack_restore(uint32_t do memcpy(&count, ptr, sizeof(count)); ptr += sizeof(count); - + if (size < sizeof(version) + sizeof(count) + count * (sizeof(struct libxl__physmap_info))) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); @@ -848,7 +946,7 @@ static void switch_logdirty_xswatch(libx rc = libxl__xs_rm_checked(gc, t, lds->ret_path); if (rc) goto out; - rc = libxl__xs_transaction_commit(gc, &t); + rc = libxl__xs_transaction_commit(gc, &t); if (!rc) break; if (rc<0) goto out; } @@ -1320,7 +1418,7 @@ void libxl__xc_domain_save_done(libxl__e if (type == LIBXL_DOMAIN_TYPE_HVM) { rc = libxl__domain_suspend_device_model(gc, dss); if (rc) goto out; - + libxl__domain_save_device_model(egc, dss, domain_suspend_done); return; } diff -r c5a851de03f1 -r 3d809b510886 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Wed Feb 13 14:51:51 2013 -0500 +++ b/tools/libxl/libxl_types.idl Wed Feb 13 16:20:24 2013 -0500 @@ -308,6 +308,8 @@ libxl_domain_build_info = Struct("domain ("vpt_align", libxl_defbool), ("timer_mode", libxl_timer_mode), ("nested_hvm", libxl_defbool), + ("smbios_firmware", string), + ("acpi_firmware", string), ("nographic", libxl_defbool), ("vga", libxl_vga_interface_info), ("vnc", libxl_vnc_info), diff -r c5a851de03f1 -r 3d809b510886 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Wed Feb 13 14:51:51 2013 -0500 +++ b/tools/libxl/xl_cmdimpl.c Wed Feb 13 16:20:24 2013 -0500 @@ -882,6 +882,11 @@ static void parse_config_data(const char } xlu_cfg_get_defbool(config, "nestedhvm", &b_info->u.hvm.nested_hvm, 0); + + xlu_cfg_replace_string(config, "smbios_firmware", + &b_info->u.hvm.smbios_firmware, 0); + xlu_cfg_replace_string(config, "acpi_firmware", + &b_info->u.hvm.acpi_firmware, 0); break; case LIBXL_DOMAIN_TYPE_PV: {
Ross Philipson
2013-Feb-13 21:52 UTC
[PATCH 3 of 3] [v3] HVM firmware passthrough libxl support
Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c Signed-off-by: Ross Philipson <ross.philipson@citrix.com> diff -r 3d809b510886 -r a5dd2f1fe65e tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Wed Feb 13 16:20:24 2013 -0500 +++ b/tools/libxl/libxl_dom.c Wed Feb 13 16:20:32 2013 -0500 @@ -31,8 +31,7 @@ libxl_domain_type libxl__domain_type(lib ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info); if (ret != 1 || info.domain != domid) { - LIBXL__LOG(CTX, LIBXL__LOG_ERROR, - "unable to get domain type for domid=%"PRIu32, domid); + LOG(ERROR, "unable to get domain type for domid=%"PRIu32, domid); return LIBXL_DOMAIN_TYPE_INVALID; } if (info.flags & XEN_DOMINF_hvm_guest) @@ -313,20 +312,19 @@ int libxl__build_post(libxl__gc *gc, uin ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *)); ents[0] = "memory/static-max"; - ents[1] = libxl__sprintf(gc, "%"PRId64, info->max_memkb); + ents[1] = GCSPRINTF("%"PRId64, info->max_memkb); ents[2] = "memory/target"; - ents[3] = libxl__sprintf(gc, "%"PRId64, - info->target_memkb - info->video_memkb); + ents[3] = GCSPRINTF("%"PRId64, info->target_memkb - info->video_memkb); ents[4] = "memory/videoram"; - ents[5] = libxl__sprintf(gc, "%"PRId64, info->video_memkb); + ents[5] = GCSPRINTF("%"PRId64, info->video_memkb); ents[6] = "domid"; - ents[7] = libxl__sprintf(gc, "%d", domid); + ents[7] = GCSPRINTF("%d", domid); ents[8] = "store/port"; - ents[9] = libxl__sprintf(gc, "%"PRIu32, state->store_port); + ents[9] = GCSPRINTF("%"PRIu32, state->store_port); ents[10] = "store/ring-ref"; - ents[11] = libxl__sprintf(gc, "%lu", state->store_mfn); + ents[11] = GCSPRINTF("%lu", state->store_mfn); for (i = 0; i < info->max_vcpus; i++) { - ents[12+(i*2)] = libxl__sprintf(gc, "cpu/%d/availability", i); + ents[12+(i*2)] = GCSPRINTF("cpu/%d/availability", i); ents[12+(i*2)+1] = libxl_bitmap_test(&info->avail_vcpus, i) ? "online" : "offline"; } @@ -335,7 +333,7 @@ int libxl__build_post(libxl__gc *gc, uin if (info->type == LIBXL_DOMAIN_TYPE_HVM) { hvm_ents = libxl__calloc(gc, 3, sizeof(char *)); hvm_ents[0] = "hvmloader/generation-id-address"; - hvm_ents[1] = libxl__sprintf(gc, "0x%lx", state->vm_generationid_addr); + hvm_ents[1] = GCSPRINTF("0x%lx", state->vm_generationid_addr); } dom_path = libxl__xs_get_dompath(gc, domid); @@ -343,7 +341,7 @@ int libxl__build_post(libxl__gc *gc, uin return ERROR_FAIL; } - vm_path = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "%s/vm", dom_path), NULL); + vm_path = xs_read(ctx->xsh, XBT_NULL, GCSPRINTF("%s/vm", dom_path), NULL); retry_transaction: t = xs_transaction_start(ctx->xsh); @@ -374,7 +372,7 @@ int libxl__build_pv(libxl__gc *gc, uint3 dom = xc_dom_allocate(ctx->xch, state->pv_cmdline, info->u.pv.features); if (!dom) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed"); + LOGE(ERROR, "xc_dom_allocate failed"); return ERROR_FAIL; } @@ -384,13 +382,13 @@ int libxl__build_pv(libxl__gc *gc, uint3 state->pv_kernel.data, state->pv_kernel.size); if ( ret != 0) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_mem failed"); + LOGE(ERROR, "xc_dom_kernel_mem failed"); goto out; } } else { ret = xc_dom_kernel_file(dom, state->pv_kernel.path); if ( ret != 0) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_kernel_file failed"); + LOGE(ERROR, "xc_dom_kernel_file failed"); goto out; } } @@ -398,12 +396,12 @@ int libxl__build_pv(libxl__gc *gc, uint3 if ( state->pv_ramdisk.path && strlen(state->pv_ramdisk.path) ) { if (state->pv_ramdisk.mapped) { if ( (ret = xc_dom_ramdisk_mem(dom, state->pv_ramdisk.data, state->pv_ramdisk.size)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_mem failed"); + LOGE(ERROR, "xc_dom_ramdisk_mem failed"); goto out; } } else { if ( (ret = xc_dom_ramdisk_file(dom, state->pv_ramdisk.path)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_ramdisk_file failed"); + LOGE(ERROR, "xc_dom_ramdisk_file failed"); goto out; } } @@ -416,31 +414,31 @@ int libxl__build_pv(libxl__gc *gc, uint3 dom->xenstore_domid = state->store_domid; if ( (ret = xc_dom_boot_xen_init(dom, ctx->xch, domid)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_xen_init failed"); + LOGE(ERROR, "xc_dom_boot_xen_init failed"); goto out; } if ( (ret = xc_dom_parse_image(dom)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_parse_image failed"); + LOGE(ERROR, "xc_dom_parse_image failed"); goto out; } if ( (ret = xc_dom_mem_init(dom, info->target_memkb / 1024)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_mem_init failed"); + LOGE(ERROR, "xc_dom_mem_init failed"); goto out; } if ( (ret = xc_dom_boot_mem_init(dom)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_mem_init failed"); + LOGE(ERROR, "xc_dom_boot_mem_init failed"); goto out; } if ( (ret = xc_dom_build_image(dom)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_build_image failed"); + LOGE(ERROR, "xc_dom_build_image failed"); goto out; } if ( (ret = xc_dom_boot_image(dom)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_image failed"); + LOGE(ERROR, "xc_dom_boot_image failed"); goto out; } if ( (ret = xc_dom_gnttab_init(dom)) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_gnttab_init failed"); + LOGE(ERROR, "xc_dom_gnttab_init failed"); goto out; } @@ -679,8 +677,7 @@ int libxl__qemu_traditional_cmd(libxl__g const char *cmd) { char *path = NULL; - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command", - domid); + path = GCSPRINTF("/local/domain/0/device-model/%d/command", domid); return libxl__xs_write(gc, XBT_NULL, path, "%s", cmd); } @@ -697,8 +694,7 @@ struct libxl__physmap_info { static inline char *restore_helper(libxl__gc *gc, uint32_t domid, uint64_t phys_offset, char *node) { - return libxl__sprintf(gc, - "/local/domain/0/device-model/%d/physmap/%"PRIx64"/%s", + return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%"PRIx64"/%s", domid, phys_offset, node); } @@ -708,7 +704,6 @@ int libxl__toolstack_restore(uint32_t do libxl__save_helper_state *shs = user; libxl__domain_create_state *dcs = CONTAINER_OF(shs, *dcs, shs); STATE_AO_GC(dcs->ao); - libxl_ctx *ctx = CTX; int i, ret; const uint8_t *ptr = buf; uint32_t count = 0, version = 0; @@ -718,7 +713,7 @@ int libxl__toolstack_restore(uint32_t do LOG(DEBUG,"domain=%"PRIu32" toolstack data size=%"PRIu32, domid, size); if (size < sizeof(version) + sizeof(count)) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); + LOG(ERROR, "wrong size"); return -1; } @@ -726,7 +721,7 @@ int libxl__toolstack_restore(uint32_t do ptr += sizeof(version); if (version != TOOLSTACK_SAVE_VERSION) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong version"); + LOG(ERROR, "wrong version"); return -1; } @@ -735,7 +730,7 @@ int libxl__toolstack_restore(uint32_t do if (size < sizeof(version) + sizeof(count) + count * (sizeof(struct libxl__physmap_info))) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "wrong size"); + LOG(ERROR, "wrong size"); return -1; } @@ -984,15 +979,13 @@ static void switch_logdirty_done(libxl__ int libxl__domain_suspend_device_model(libxl__gc *gc, libxl__domain_suspend_state *dss) { - libxl_ctx *ctx = libxl__gc_owner(gc); int ret = 0; uint32_t const domid = dss->domid; const char *const filename = dss->dm_savefile; switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, - "Saving device model state to %s", filename); + LOG(DEBUG, "Saving device model state to %s", filename); libxl__qemu_traditional_cmd(gc, domid, "save"); libxl__wait_for_device_model(gc, domid, "paused", NULL, NULL, NULL); break; @@ -1168,8 +1161,7 @@ int libxl__domain_suspend_common_callbac static inline char *physmap_path(libxl__gc *gc, uint32_t domid, char *phys_offset, char *node) { - return libxl__sprintf(gc, - "/local/domain/0/device-model/%d/physmap/%s/%s", + return GCSPRINTF("/local/domain/0/device-model/%d/physmap/%s/%s", domid, phys_offset, node); } @@ -1186,7 +1178,7 @@ int libxl__toolstack_save(uint32_t domid char **entries = NULL; struct libxl__physmap_info *pi; - entries = libxl__xs_directory(gc, 0, libxl__sprintf(gc, + entries = libxl__xs_directory(gc, 0, GCSPRINTF( "/local/domain/0/device-model/%d/physmap", domid), &num); count = num; @@ -1327,7 +1319,7 @@ void libxl__domain_suspend(libxl__egc *e char *path; char *addr; - path = libxl__sprintf(gc, "%s/hvmloader/generation-id-address", + path = GCSPRINTF("%s/hvmloader/generation-id-address", libxl__xs_get_dompath(gc, domid)); addr = libxl__xs_read(gc, XBT_NULL, path); @@ -1541,10 +1533,7 @@ static void domain_suspend_done(libxl__e char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid) { - char *s = libxl__sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid)); - if (!s) - LIBXL__LOG(libxl__gc_owner(gc), LIBXL__LOG_ERROR, "cannot allocate for uuid"); - return s; + return GCSPRINTF(LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid)); } static const char *userdata_path(libxl__gc *gc, uint32_t domid, @@ -1552,34 +1541,27 @@ static const char *userdata_path(libxl__ const char *wh) { libxl_ctx *ctx = libxl__gc_owner(gc); - char *path, *uuid_string; + char *uuid_string; libxl_dominfo info; int rc; rc = libxl_domain_info(ctx, &info, domid); if (rc) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to find domain info" - " for domain %"PRIu32, domid); + LOGE(ERROR, "unable to find domain info for domain %"PRIu32, domid); return NULL; } - uuid_string = libxl__sprintf(gc, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info.uuid)); + uuid_string = GCSPRINTF(LIBXL_UUID_FMT, LIBXL_UUID_BYTES(info.uuid)); - path = libxl__sprintf(gc, "/var/lib/xen/" - "userdata-%s.%u.%s.%s", - wh, domid, uuid_string, userdata_userid); - if (!path) - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to allocate for" - " userdata path"); - return path; + return GCSPRINTF("/var/lib/xen/userdata-%s.%u.%s.%s", + wh, domid, uuid_string, userdata_userid); } static int userdata_delete(libxl__gc *gc, const char *path) { - libxl_ctx *ctx = libxl__gc_owner(gc); int r; r = unlink(path); if (r) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "remove failed for %s", path); + LOGE(ERROR, "remove failed for %s", path); return errno; } return 0; @@ -1587,7 +1569,6 @@ static int userdata_delete(libxl__gc *gc void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid) { - libxl_ctx *ctx = libxl__gc_owner(gc); const char *pattern; glob_t gl; int r, i; @@ -1603,7 +1584,7 @@ void libxl__userdata_destroyall(libxl__g if (r == GLOB_NOMATCH) goto out; if (r) - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "glob failed for %s", pattern); + LOGE(ERROR, "glob failed for %s", pattern); for (i=0; i<gl.gl_pathc; i++) { userdata_delete(gc, gl.gl_pathv[i]);
Ian Campbell
2013-Feb-15 13:39 UTC
Re: [PATCH 0 of 3] [v3] HVM firmware passthrough libxl support
On Wed, 2013-02-13 at 21:52 +0000, Ross Philipson wrote:> This patch series is a follow-up to the earlier HVM firmware passthrough > patch set. It introduces support in libxl for specifying and loading the > ACPI and SMBIOS firmware blobs that are passed to libxc. > > There are 3 patches in the series: > 01 - Switch xl to use the new xc_hvm_build() libxc API. > 02 - Xen xl toolstack changes to load ACPI and SMBIOS firmware files. > Doc changes to the man page for xl.cfg describing the new params. > 03 - Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c > > This version cleans up some of the logging and error handling in the > new firmware passthrough code. > > Signed-off-by: Ross Philipson <ross.philipson@citrix.com>Acked + applied. All three patches had the same title here, please give patches unique and descriptive titles in the future. I retitled them as: libxl: switch to using the new xc_hvm_build() libxc API. libxl: HVM firmware passthrough support libxl: Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c
Ross Philipson
2013-Feb-15 17:31 UTC
Re: [PATCH 0 of 3] [v3] HVM firmware passthrough libxl support
Wilco, thank you.> -----Original Message----- > From: Ian Campbell > Sent: Friday, February 15, 2013 8:39 AM > To: Ross Philipson > Cc: xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] [PATCH 0 of 3] [v3] HVM firmware passthrough > libxl support > > On Wed, 2013-02-13 at 21:52 +0000, Ross Philipson wrote: > > This patch series is a follow-up to the earlier HVM firmware > passthrough > > patch set. It introduces support in libxl for specifying and loading > the > > ACPI and SMBIOS firmware blobs that are passed to libxc. > > > > There are 3 patches in the series: > > 01 - Switch xl to use the new xc_hvm_build() libxc API. > > 02 - Xen xl toolstack changes to load ACPI and SMBIOS firmware files. > > Doc changes to the man page for xl.cfg describing the new params. > > 03 - Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c > > > > This version cleans up some of the logging and error handling in the > > new firmware passthrough code. > > > > Signed-off-by: Ross Philipson <ross.philipson@citrix.com> > > Acked + applied. All three patches had the same title here, please give > patches unique and descriptive titles in the future. I retitled them as: > > libxl: switch to using the new xc_hvm_build() libxc API. > libxl: HVM firmware passthrough support > libxl: Cleanup, use LOG* and GCSPRINTF macro in libxl_dom.c > >