Re: [PATCH 08/11] qemu: Simplify QEMU binary search

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

 



On Thu, Sep 20, 2018 at 05:25:26PM +0200, Andrea Bolognani wrote:
> Now that we have reduced the number of sensible options down
> to either the native QEMU binary or RHEL's qemu-kvm, we can
> make virQEMUCapsInitGuest() a bit simpler.
> 
> Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
> ---
>  src/qemu/qemu_capabilities.c | 29 +++++++----------------------
>  1 file changed, 7 insertions(+), 22 deletions(-)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index fd8badc60b..72fa19a2b7 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -746,7 +746,6 @@ virQEMUCapsInitGuest(virCapsPtr caps,
>                       virArch hostarch,
>                       virArch guestarch)
>  {
> -    size_t i;
>      char *binary = NULL;
>      virQEMUCapsPtr qemubinCaps = NULL;
>      int ret = -1;
> @@ -756,6 +755,13 @@ virQEMUCapsInitGuest(virCapsPtr caps,
>       */
>      binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
>  
> +    /* RHEL doesn't follow the usual naming for QEMU binaries and ships
> +     * a single binary named qemu-kvm outside of $PATH instead */
> +    if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) {
> +        if (VIR_STRDUP(binary, "/usr/libexec/qemu-kvm") < 0)
> +            return -1;
> +    }
> +
>      /* Ignore binary if extracting version info fails */
>      if (binary) {
>          if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
> @@ -764,27 +770,6 @@ virQEMUCapsInitGuest(virCapsPtr caps,
>          }
>      }
>  
> -    if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) {
> -        const char *kvmbins[] = {
> -            "/usr/libexec/qemu-kvm", /* RHEL */
> -        };
> -
> -        for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
> -            binary = virFindFileInPath(kvmbins[i]);
> -
> -            if (!binary)
> -                continue;
> -
> -            if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
> -                virResetLastError();
> -                VIR_FREE(binary);
> -                continue;
> -            }
> -
> -            break;
> -        }
> -    }

This patch is doing two things. It is moving the code block earlier,
to let you drop the duplicated virQEMUCapsCacheLookup(). Second it is
removing the array iteration & just checking one single path instead.

I'd suggest we keep the array iteration, and just move the code.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
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]

  Powered by Linux