Jim Fehlig wrote:
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(a)eu.citrix.com>
> ---
> 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().
Daniel already clarified this, so no need to do even more work David :).
As mentioned in my other response [1], your original patch (with a check
to verify the requested emulator exists) should be sufficient.
Regards,
Jim
[1]
https://www.redhat.com/archives/libvir-list/2013-April/msg02087.html