[libvirt] [RFC 5/6] qemu: Fill in GIC capabilities

Andrea Bolognani abologna at redhat.com
Wed Apr 6 15:23:12 UTC 2016


On Wed, 2016-03-30 at 16:12 -0400, John Ferlan wrote:
> On 03/21/2016 01:28 PM, Andrea Bolognani wrote:
> > +static int
> > +virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
> > +                                    virDomainCapsPtr domCaps)
> > +{
> > +    virDomainCapsFeatureGICPtr gic = &domCaps->gic;
> > +    size_t i;
> > +
> > +    if (domCaps->arch != VIR_ARCH_ARMV7L &&
> > +        domCaps->arch != VIR_ARCH_AARCH64)
> > +        return 0;
> > +
> > +    if (STRNEQ(domCaps->machine, "virt") &&
> > +        !STRPREFIX(domCaps->machine, "virt-"))
> > +        return 0;
> > +
> > +    for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
> > +        virGICCapabilityPtr cap = &qemuCaps->gicCapabilities[i];
> > +
> > +        if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM &&
> > +            !(cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL))
> > +            continue;
> > +
> > +        if (domCaps->virttype == VIR_DOMAIN_VIRT_QEMU &&
> > +            !(cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED))
> > +            continue;
> 
> For these, patch 6 would need to be already in place I think if
> circumstances were "just right" (so to speak).

The feature is not really expected to work properly until the
entire series has been applied, right?

We can still shuffle patches around to implement proper caching
of the capabilities even before such capabilities are actually
filled in, but I don't think it's a blocker per se.

> > +
> > +        gic->supported = true;
> > +        VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
> > +                                 cap->version);
> 
> Can there be more than one?

Definitely! An example is hardware supporting both GIC v2
and GIC v3; another one is QEMU eventually implementing an
emulated GIC v3. In both cases we'll end up with

  <features>
    <gic supported='yes'>
      <enum name='version'>
        <value>2</value>
        <value>3</value>
      </enum>
    </gic>
  </features>

> How is that handled!

With a bit of magic, really ;)

Basically virDomainCapsEnumSet() packs enum values very
tightly, as if they were declared as flags to begin with,
and virDomainCapsFormat() later unpacks them and presents
them as above.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team




More information about the libvir-list mailing list