[libvirt] [PATCH 15/41] qemu: Introduce virQEMUCapsGuestIsNative

Jiri Denemark jdenemar at redhat.com
Wed Sep 14 08:57:57 UTC 2016


On Mon, Aug 29, 2016 at 17:56:29 -0400, John Ferlan wrote:
...
> > @@ -852,7 +863,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
> >           * arm is different in that 32-on-64 _only_ works with
> >           * qemu-system-aarch64. So we have to add it to the kvmbins list
> >           */
> > -        if (arm_32on64_kvm)
> > +        if (hostarch == VIR_ARCH_AARCH64 && guestarch == VIR_ARCH_ARMV7L)
> >              kvmbins[3] = "qemu-system-aarch64";
> >  
> >          for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
> > 
> 
> Noted by Coverity in this module - existing I think as well, it's just
> that the change piqued Coverity's interest in analyzing things...
> 
> At the top of this function we have a:
> 
>      /* Ignore binary if extracting version info fails */
>      if (binary) {
>          if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
>              virResetLastError();
> ...
> 
> Then there's the replace if condition w/ virQEMUCapsGuestIsNative
> followed by a:
> 
>     ret = virQEMUCapsInitGuestFromBinary(caps,
>                                          binary, qemubinCaps,
>                                          kvmbin, kvmbinCaps,
>                                          guestarch);
> 
> where it's noted that virQEMUCapsInitGuestFromBinary will dereference
> qemubinCaps in the call to virQEMUCapsGetMachineTypesCaps and it's
> possible that qemubinCaps is NULL if "binary" is set. The analysis
> doesn't go into the virQEMUCapsGuestIsNative condition. It's also
> notable that if !binary is checked in virQEMUCapsInitGuestFromBinary, so
> this is somewhat of an "edge" condition.

That's impossible, see

    if (binary) {
        if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
            virResetLastError();
            VIR_FREE(binary);
        }
    }

Jirka




More information about the libvir-list mailing list