Re: [PATCH 2/2] libxl: allow an <emulator> to be selected in the domain config XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Scott wrote:
> We cross-check the given path against the capabilties, and translate
> it into a libxl_device_model_version.
>
> Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>
> ---
>  src/libxl/libxl_conf.c |   41 +++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 472d116..868d0cf 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -75,6 +75,11 @@ static const char* emulator_lib32_path [] = {
>      EMULATOR_LIB32 EMULATOR_UPSTREAM,
>  };
>  
> +static const libxl_device_model_version emulator_to_device_model [] = {
> +    LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL,
> +    LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN,
> +};
> +
>  struct guest_arch {
>      virArch arch;
>      int bits;
> @@ -833,6 +838,38 @@ libxlMakeCapabilities(libxl_ctx *ctx)
>  }
>  
>  int
> +libxlMakeEmulator(virDomainDefPtr def, libxl_domain_config *d_config)
> +{
> +    virArch hostarch;
> +    const char *path;
> +    int i;
> +
> +    /* No explicit override means use the default */
> +    if (!def->emulator) {
> +        return 0;
> +    }
> +
> +    hostarch = virArchFromHost();
> +
> +    for (i = 0; i < emulator_last; ++i) {
> +       path = ((hostarch == VIR_ARCH_X86_64) ?
> +               emulator_lib64_path[i] :
> +               emulator_lib32_path[i]);
> +       if (STREQ(path, def->emulator)) {
>   

I thought there was a virCapabilitiesSupportsGuestEmulator() or similar,
but I don't see it in src/conf/capabilities.c.  I think it makes sense
to add such a function to the capabilities and then just call it here,
passing the requested emulator.  Perhaps other libvirt developers can
comment on the usefulness of virCapabilitiesSupportGuestEmulator().

> +           d_config->b_info.device_model_version =
> +               emulator_to_device_model[i];
> +           return 0;
> +       }
> +    }
> +
> +    virReportError(VIR_ERR_INTERNAL_ERROR,
> +                   _("libxenlight doesn't support emulator '%s'"),
> +                   def->emulator);
> +    return -1;
> +}
> +
> +
> +int
>  libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
>                         virDomainDefPtr def, libxl_domain_config *d_config)
>  {
> @@ -856,6 +893,10 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
>          goto error;
>      }
>  
> +    if (libxlMakeEmulator(def, d_config) < 0) {
>   

The capabilities created when the libxl driver is loaded are available
in libxlDriverPrivatePtr and could be passed to libxlMakeEmulator()

libxlMakeEmulator(driver->caps, def, d_config)

Regards,
Jim

> +        goto error;
> +    }
> +
>      d_config->on_reboot = def->onReboot;
>      d_config->on_poweroff = def->onPoweroff;
>      d_config->on_crash = def->onCrash;
>   

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]