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)) {
+ 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) {
+ goto error;
+ }
+
d_config->on_reboot = def->onReboot;
d_config->on_poweroff = def->onPoweroff;
d_config->on_crash = def->onCrash;
--
1.7.1