[libvirt] [PATCH] Look in /usr/libexec for the qemu-kvm binary.
Daniel Veillard
veillard at redhat.com
Mon Feb 1 15:12:26 UTC 2010
On Wed, Jan 27, 2010 at 09:23:50AM -0500, Chris Lalancette wrote:
> On RHEL-5 the qemu-kvm binary is located in /usr/libexec.
> To reduce confusion for people trying to run upstream libvirt
> on RHEL-5 machines, make the qemu driver look in /usr/libexec
> for the qemu-kvm binary.
>
> To make this work, I modified virFindFileInPath to handle an
> absolute path correctly. I also ran into an issue where
> NULL was sometimes being passed for the file parameter
> to virFindFileInPath; it didn't crash prior to this patch
> since it was building paths like /usr/bin/(null). This
> is non-standard behavior, though, so I added a NULL
> check at the beginning.
>
> Signed-off-by: Chris Lalancette <clalance at redhat.com>
> ---
> src/qemu/qemu_conf.c | 3 ++-
> src/util/util.c | 13 +++++++++++++
> 2 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index f4a6c08..d5e38c2 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -804,7 +804,8 @@ qemudCapsInitGuest(virCapsPtr caps,
> if (STREQ(info->arch, hostmachine) ||
> (STREQ(hostmachine, "x86_64") && STREQ(info->arch, "i686"))) {
> if (access("/dev/kvm", F_OK) == 0) {
> - const char *const kvmbins[] = { "qemu-kvm", /* Fedora */
> + const char *const kvmbins[] = { "/usr/libexec/qemu-kvm", /* RHEL */
> + "qemu-kvm", /* Fedora */
> "kvm" }; /* Upstream .spec */
>
> for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
> diff --git a/src/util/util.c b/src/util/util.c
> index 0ce5026..394ef35 100644
> --- a/src/util/util.c
> +++ b/src/util/util.c
> @@ -1114,6 +1114,19 @@ char *virFindFileInPath(const char *file)
> char *pathseg;
> char fullpath[PATH_MAX];
>
> + if (file == NULL)
> + return NULL;
> +
> + /* if we are passed an absolute path (starting with /), return a
> + * copy of that path
> + */
> + if (file[0] == '/') {
> + if (virFileExists(file))
> + return strdup(file);
> + else
> + return NULL;
> + }
> +
> /* copy PATH env so we can tweak it */
> if (virStrcpyStatic(pathenv, getenv("PATH")) == NULL)
> return NULL;
ACK, makes sense !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list