From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Anthony PERARD <anthony.perard@citrix.com>, xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v7 05/15] libxl: Load guest BIOS from file
Date: Mon, 15 Aug 2016 17:04:20 +0800 [thread overview]
Message-ID: <57B18594.8060802@huawei.com> (raw)
In-Reply-To: <20160728105013.22310-6-anthony.perard@citrix.com>
On 2016/7/28 18:50, Anthony PERARD wrote:
> The path to the BIOS blob can be overriden by the xl's
> bios_path_override option, or provided by u.hvm.bios_firmware in the
> domain_build_info struct by other libxl user.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
>
> ---
> Changes in V6:
> - use goto for error handling of libxl__load_hvm_firmware_module()
>
> Changes in V5:
> - man page, use B<> to highlight config option in description.
> - rename config option from `bios_override` to `bios_path_override`
> - store libxl_read_file_contents() return value into r instead of e
> (just renamed the variable)
> - rename domain_build_info.u.hvm.bios_firmware to system_firmware
>
> Changes in V4:
> - updating man page to have bios_override described.
> - return ERROR_INVAL in libxl__load_hvm_firmware_module when the file is
> empty.
>
> Changes in V3:
> - move seabios_path and ovmf_path to libxl_path.c (with renaming)
> - fix some coding style
> - warn for empty file
> - remove rombios stuff (will still be built-in hvmloader)
> - rename field bios_filename in domain_build_info to bios_firmware to
> follow naming of acpi and smbios.
> - log an error after libxl_read_file_contents() only when it return ENOENT
> - return an error on empty file.
> - added #define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
> ---
> docs/man/xl.cfg.pod.5.in | 9 +++++++
> tools/libxl/libxl.h | 8 ++++++
> tools/libxl/libxl_dom.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
> tools/libxl/libxl_internal.h | 2 ++
> tools/libxl/libxl_paths.c | 10 ++++++++
> tools/libxl/libxl_types.idl | 1 +
> tools/libxl/xl_cmdimpl.c | 11 +++++---
> 7 files changed, 99 insertions(+), 3 deletions(-)
>
> diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
> index 3bb27d0..a685b83 100644
> --- a/docs/man/xl.cfg.pod.5.in
> +++ b/docs/man/xl.cfg.pod.5.in
> @@ -1212,6 +1212,15 @@ Requires device_model_version=qemu-xen.
>
> =back
>
> +=item B<bios_path_override="PATH">
> +
> +Override the path to the blob to be used as BIOS. The blob provided here MUST
> +be consistent with the B<bios=> which you have specified. You should not
> +normally need to specify this option.
> +
> +This options does not have any effect if using B<bios="rombios"> or
> +B<device_model_version="qemu-xen-traditional">.
> +
> =item B<pae=BOOLEAN>
>
> Hide or expose the IA32 Physical Address Extensions. These extensions
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 48a43ce..5cccdc8 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -942,6 +942,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
> #define LIBXL_HAVE_CHECKPOINTED_STREAM 1
>
> /*
> + * LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
> + *
> + * libxl_domain_build_info has u.hvm.system_firmware field which can be use
> + * to provide a different firmware blob (like SeaBIOS or OVMF).
> + */
> +#define LIBXL_HAVE_BUILDINFO_HVM_SYSTEM_FIRMWARE
> +
> +/*
> * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it
> * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7
> */
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index ec29060..2a1793d 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -862,6 +862,42 @@ err:
> return ret;
> }
>
> +static int libxl__load_hvm_firmware_module(libxl__gc *gc,
> + const char *filename,
> + const char *what,
> + struct xc_hvm_firmware_module *m)
> +{
> + int datalen = 0;
> + void *data = NULL;
> + int r, rc;
> +
> + LOG(DEBUG, "Loading %s: %s", what, filename);
> + r = libxl_read_file_contents(CTX, filename, &data, &datalen);
> + if (r) {
> + /*
> + * Print a message only on ENOENT, other errors are logged by the
> + * function libxl_read_file_contents().
> + */
> + if (r == ENOENT)
> + LOGEV(ERROR, r, "failed to read %s file", what);
> + rc = ERROR_FAIL;
> + goto out;
> + }
> + libxl__ptr_add(gc, data);
> + if (datalen) {
> + /* Only accept non-empty files */
> + m->data = data;
> + m->length = datalen;
> + } else {
> + LOG(ERROR, "file %s for %s is empty", filename, what);
> + rc = ERROR_INVAL;
> + goto out;
> + }
> + rc = 0;
> +out:
> + return rc;
> +}
> +
> static int libxl__domain_firmware(libxl__gc *gc,
> libxl_domain_build_info *info,
> struct xc_dom_image *dom)
> @@ -871,6 +907,7 @@ static int libxl__domain_firmware(libxl__gc *gc,
> int e, rc;
> int datalen = 0;
> void *data;
> + const char *bios_filename = NULL;
>
> if (info->u.hvm.firmware)
> firmware = info->u.hvm.firmware;
> @@ -914,6 +951,30 @@ static int libxl__domain_firmware(libxl__gc *gc,
> goto out;
> }
>
> + if (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
> + if (info->u.hvm.system_firmware) {
> + bios_filename = info->u.hvm.system_firmware;
> + } else {
> + switch (info->u.hvm.bios) {
> + case LIBXL_BIOS_TYPE_SEABIOS:
> + bios_filename = libxl__seabios_path();
> + break;
> + case LIBXL_BIOS_TYPE_OVMF:
> + bios_filename = libxl__ovmf_path();
> + break;
> + case LIBXL_BIOS_TYPE_ROMBIOS:
> + default:
> + abort();
> + }
> + }
> + }
> +
> + if (bios_filename) {
> + rc = libxl__load_hvm_firmware_module(gc, bios_filename, "BIOS",
> + &dom->system_firmware_module);
> + if (rc) goto out;
> + }
> +
> if (info->u.hvm.smbios_firmware) {
> data = NULL;
> e = libxl_read_file_contents(ctx, info->u.hvm.smbios_firmware,
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 5347b69..991a1cc 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -2320,6 +2320,8 @@ _hidden const char *libxl__xen_config_dir_path(void);
> _hidden const char *libxl__xen_script_dir_path(void);
> _hidden const char *libxl__lock_dir_path(void);
> _hidden const char *libxl__run_dir_path(void);
> +_hidden const char *libxl__seabios_path(void);
> +_hidden const char *libxl__ovmf_path(void);
>
> /*----- subprocess execution with timeout -----*/
>
> diff --git a/tools/libxl/libxl_paths.c b/tools/libxl/libxl_paths.c
> index 9b7b0d5..6972b90 100644
> --- a/tools/libxl/libxl_paths.c
> +++ b/tools/libxl/libxl_paths.c
> @@ -35,6 +35,16 @@ const char *libxl__run_dir_path(void)
> return XEN_RUN_DIR;
> }
>
> +const char *libxl__seabios_path(void)
> +{
> + return SEABIOS_PATH;
> +}
> +
> +const char *libxl__ovmf_path(void)
> +{
> + return OVMF_PATH;
> +}
> +
Hi, I got bellow errors when compiling on ARM.
libxl_paths.c: In function 'libxl__seabios_path':
libxl_paths.c:40:12: error: 'SEABIOS_PATH' undeclared (first use in this
function)
return SEABIOS_PATH;
^
libxl_paths.c:40:12: note: each undeclared identifier is reported only
once for each function it appears in
libxl_paths.c: In function 'libxl__ovmf_path':
libxl_paths.c:45:12: error: 'OVMF_PATH' undeclared (first use in this
function)
return OVMF_PATH;
^
libxl_paths.c: In function 'libxl__seabios_path':
libxl_paths.c:41:1: error: control reaches end of non-void function
[-Werror=return-type]
}
^
libxl_paths.c: In function 'libxl__ovmf_path':
libxl_paths.c:46:1: error: control reaches end of non-void function
[-Werror=return-type]
}
^
cc1: all warnings being treated as errors
Thanks,
--
Shannon
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-15 9:04 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 10:49 [PATCH v7 00/15] Load BIOS via toolstack instead of been embedded in hvmloader Anthony PERARD
2016-07-28 10:49 ` [PATCH v7 01/15] libxc: Rework extra module initialisation Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 02/15] libxc: Prepare a start info structure for hvmloader Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 03/15] configure: #define SEABIOS_PATH and OVMF_PATH Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 04/15] firmware/makefile: install BIOS blob Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 05/15] libxl: Load guest BIOS from file Anthony PERARD
2016-08-15 9:04 ` Shannon Zhao [this message]
2016-08-15 9:09 ` Wei Liu
2016-08-15 9:14 ` Shannon Zhao
2016-08-15 9:17 ` Wei Liu
2016-07-28 10:50 ` [PATCH v7 06/15] xen: Move the hvm_start_info C representation to the public headers Anthony PERARD
2016-07-28 13:23 ` Andrew Cooper
2016-08-03 15:43 ` Jan Beulich
2016-07-28 10:50 ` [PATCH v7 07/15] hvmloader: Grab the hvm_start_info pointer Anthony PERARD
2016-07-28 14:09 ` Andrew Cooper
2016-07-28 10:50 ` [PATCH v7 08/15] hvmloader: Locate the BIOS blob Anthony PERARD
2016-07-28 13:44 ` Andrew Cooper
2016-08-02 18:14 ` Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 09/15] hvmloader: Check modules whereabouts in perform_tests Anthony PERARD
2016-07-28 14:08 ` Andrew Cooper
2016-08-02 18:34 ` Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 10/15] hvmloader: Load SeaBIOS from hvm_start_info modules Anthony PERARD
2016-07-28 14:09 ` Andrew Cooper
2016-07-28 10:50 ` [PATCH v7 11/15] hvmloader: Load OVMF from modules Anthony PERARD
2016-07-28 14:11 ` Andrew Cooper
2016-07-28 10:50 ` [PATCH v7 12/15] hvmloader: bios->bios_load() now needs to be defined Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 13/15] hvmloader: Always build-in SeaBIOS and OVMF loader Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 14/15] configure: do not depend on SEABIOS_PATH or OVMF_PATH Anthony PERARD
2016-07-28 10:50 ` [PATCH v7 15/15] docs/misc/hvmlite: Point to the canonical definition of hvm_start_info Anthony PERARD
2016-08-01 12:29 ` Jan Beulich
2016-07-29 5:28 ` [PATCH v7 00/15] Load BIOS via toolstack instead of been embedded in hvmloader Boris Ostrovsky
2016-07-29 8:29 ` Wei Liu
2016-07-29 14:36 ` Boris Ostrovsky
2016-07-29 14:50 ` Wei Liu
2016-07-29 14:57 ` Boris Ostrovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57B18594.8060802@huawei.com \
--to=zhaoshenglong@huawei.com \
--cc=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).