[libvirt] [PATCH] libxl: allow an <emulator> to be selected in the domain config XML
Jim Fehlig
jfehlig at suse.com
Tue Apr 30 15:10:21 UTC 2013
David Scott wrote:
> The emulator path supplied can be any valid path on the system.
>
> Note that when setting a device_model, libxl needs us to set the
> device_model_version too. The device_model_version can be either
>
> ...QEMU_XEN: meaning "upstream qemu", the default in xen-4.3 onwards
> ...QEMU_XEN_TRADITIONAL: the old xen-specific fork
>
> We detect the device_model_version by examining the qemu filename:
> if it is "qemu-dm" then it's the old xen-specific fork. If anything
> else then we assume "upstream qemu" (whose filename may change
> in future). Note that if you are using a wrapper script to (eg)
> adjust the arguments of the old qemu during development, you will
> have to ensure the wrapper script also has the name "qemu-dm", by
> placing it in a separate directory.
>
That is unfortunate. Users could have existing config with
<emulator>/usr/bin/my-qemu-dm</emulator> which works with the legacy
stack but not with libxl right? Is it possible to safely query the
binary to determine if it is qemu-dm?
Regards,
Jim
> Signed-off-by: David Scott <dave.scott at eu.citrix.com>
> ---
> src/libxl/libxl_conf.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 7e0753a..2aa5a62 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -788,6 +788,46 @@ libxlMakeCapabilities(libxl_ctx *ctx)
> }
>
> int
> +libxlMakeEmulator(virDomainDefPtr def, libxl_domain_config *d_config)
> +{
> + /* No explicit override means use the default */
> + if (!def->emulator) {
> + return 0;
> + }
> +
> + if (!virFileExists(def->emulator)) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + _("emulator '%s' not found"),
> + def->emulator);
> + return -1;
> + }
> +
> + VIR_FREE(d_config->b_info.device_model);
> + if ((d_config->b_info.device_model = strdup(def->emulator)) == NULL) {
> + virReportOOMError();
> + return -1;
> + }
> +
> + /* N.B. from xen/tools/libxl/libxl_types.idl:
> + * "If setting device_model you must set device_model_version too."
> + *
> + * The xen-4.3 and later default is "upstream qemu" (QEMU_XEN)
> + * so we make that the default and special-case the old-style
> + * "traditional qemu" (QEMU_XEN_TRADITIONAL)
> + */
> +
> + d_config->b_info.device_model_version =
> + LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
> +
> + if (STREQ(basename(def->emulator), "qemu-dm"))
> + d_config->b_info.device_model_version =
> + LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
> +
> + return 0;
> +}
> +
> +
> +int
> libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
> virDomainDefPtr def, libxl_domain_config *d_config)
> {
> @@ -811,6 +851,10 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
> goto error;
> }
>
> + if (libxlMakeEmulator(def, d_config) < 0) {
> + goto error;
> + }
> +
> d_config->on_reboot = def->onReboot;
> d_config->on_poweroff = def->onPoweroff;
> d_config->on_crash = def->onCrash;
>
More information about the libvir-list
mailing list