diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-04-20 17:13:00 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-04-20 17:13:00 +0100 |
commit | f0adb65d3adf6e7dc31169b227d1cbeba84920c3 (patch) | |
tree | e3915167aa9e1891f08d83b472e1b2fa0618fdcc /tools/libxl/libxl_utils.c | |
parent | 0cb2a574211b9055790116a9066ebc3acbbba7e7 (diff) | |
download | xen-f0adb65d3adf6e7dc31169b227d1cbeba84920c3.tar.gz xen-f0adb65d3adf6e7dc31169b227d1cbeba84920c3.tar.bz2 xen-f0adb65d3adf6e7dc31169b227d1cbeba84920c3.zip |
tools: libxl: hide selection of device-model by default.
This should never have been exposed to users as something they are
required to think about, unless they want to.
At the libxl API level:
* Add libxl_device_model_info.device_model_version allowing the
user to say which qemu version (e.g. old qemu-xen or qemu
upstream) they want for a domain.
* Add libxl_device_model_info.device_model_stubdomain allowing
the user to select stub or non-stub device model
* Default both the device_model field to NULL and DTRT when
building a domain with that value in those fields, but still
allow libxl users to specify something explicit if they want.
* Note that libxl_device_model_info.device_model, if specified,
must now be a complete path.
At the xl level:
* Support a new "device_model_version" option which sets the new
libxl_device_model_info.device_model_version field. This
option is mandatory if device_model_override is used.
* Support a new "device_model_stubdomain_override" option which
allows the user to request stubdomain if desired.
* WARN if an HVM guest cfg uses the "device_model" config
option, and direct users to the "device_model_override" option
if they really do not want the default. If the "device_model"
directive contains "stubdom-db" then direct users to the
"device_model_stubdomain_override" directive.
The default qemu remains the existing qemu-xen based qemu-dm and
stubdomain defaults to off. I chose the name "qemu-xen traditional" to
refer to the existing Xen fork of qemu and simply "qemu-xen" to refer to
the new device model based on qemu upstream.
I suspect that the vast majority of users only have these config
options because they've copied them from somewhere and they normally
have no interest in which device model is used. Renaming the fields
and warning when they are used makes these decisions internal. This
will allow us to make decisions at a platform level regarding the
preferred hvmloader, device model, stub domain etc without requiring
everyone to change their configuration files.
Adding a device model version to the API is intended to make it easy
for users to select what they need without having to know about the
paths to specific binaries etc. Most importantly it gets rid of the
parsing of the output of qemu -h...
It's not clear where upstream qemu will eventually be installed, I
went with /usr/bin/qemu for now.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_utils.c')
-rw-r--r-- | tools/libxl/libxl_utils.c | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 4e59fe6365..38e9157f73 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -568,89 +568,6 @@ out: return rc; } -#define QEMU_VERSION_STR "QEMU emulator version " - - -int libxl_check_device_model_version(libxl_ctx *ctx, char *path) -{ - libxl__gc gc = LIBXL_INIT_GC(ctx); - pid_t pid = -1; - int pipefd[2]; - char buf[100]; - ssize_t i, count = 0; - int status; - char *abs_path = NULL; - int rc = -1; - - abs_path = libxl__abs_path(&gc, path, libxl_private_bindir_path()); - - if (pipe(pipefd)) - goto out; - - pid = fork(); - if (pid == -1) { - goto out; - } - - if (!pid) { - close(pipefd[0]); - if (dup2(pipefd[1], STDOUT_FILENO) == -1) - exit(1); - execlp(abs_path, abs_path, "-h", NULL); - - close(pipefd[1]); - exit(127); - } - - close(pipefd[1]); - - /* attempt to get the first line of `qemu -h` */ - while ((i = read(pipefd[0], buf + count, 99 - count)) > 0) { - if (i + count > 90) - break; - for (int j = 0; j < i; j++) { - if (buf[j + count] == '\n') - break; - } - count += i; - } - count += i; - close(pipefd[0]); - waitpid(pid, &status, 0); - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - goto out; - } - - /* Check if we have the forked qemu-xen. */ - /* QEMU-DM emulator version 0.10.2, ... */ - if (strncmp("QEMU-DM ", buf, 7) == 0) { - rc = 0; - goto out; - } - - /* Check if the version is above 12.0 */ - /* The first line is : QEMU emulator version 0.12.50, ... */ - if (strncmp(QEMU_VERSION_STR, buf, strlen(QEMU_VERSION_STR)) == 0) { - int major, minor; - char *endptr = NULL; - char *v = buf + strlen(QEMU_VERSION_STR); - - major = strtol(v, &endptr, 10); - if (major == 0 && endptr && *endptr == '.') { - v = endptr + 1; - minor = strtol(v, &endptr, 10); - if (minor >= 12) { - rc = 1; - goto out; - } - } - } - rc = 0; -out: - libxl__free_all(&gc); - return rc; -} - int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap) { int max_cpus; |