On 05/16/2016 06:00 PM, Andrea Bolognani wrote: > This utility function extracts some of the logic from > virQEMUCapsFillDomainFeatureGICCaps() so that it can be used > in a different context. > --- > src/qemu/qemu_capabilities.c | 62 ++++++++++++++++++++++++++++++++++++-------- > src/qemu/qemu_capabilities.h | 4 +++ > 2 files changed, 55 insertions(+), 11 deletions(-) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index fcfd1cd..9055bf9 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -4258,6 +4258,49 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, > > > /** > + * virQEMUCapsSupportsGICVersion: > + * @qemuCaps: QEMU capabilities > + * @virtType: domain type > + * @version: GIC version > + * > + * Checks the QEMU binary with capabilities @qemuCaps supports a specific > + * GIC version for a domain of type @virtType. > + * > + * Returns: true if the binary supports the requested GIC version, false > + * otherwise > + */ > +bool > +virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps, > + virDomainVirtType virtType, > + virGICVersion version) > +{ > + size_t i; > + bool ret = false; remove > + > + for (i = 0; i < qemuCaps->ngicCapabilities; i++) { > + virGICCapabilityPtr cap = &(qemuCaps->gicCapabilities[i]); > + > + if (cap->version != version) > + continue; > + > + if (virtType == VIR_DOMAIN_VIRT_KVM && > + cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL) { > + ret = true; Just return true (no need for {} either) > + break; > + } > + > + if (virtType == VIR_DOMAIN_VIRT_QEMU && > + cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED) { > + ret = true; Same here > + break; > + } > + } > + > + return ret; return false ACK w/ those adjustments John > +} > + > + > +/** > * virQEMUCapsFillDomainFeatureGICCaps: > * @qemuCaps: QEMU capabilities > * @domCaps: domain capabilities > @@ -4281,7 +4324,7 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps, > virDomainCapsPtr domCaps) > { > virDomainCapsFeatureGICPtr gic = &domCaps->gic; > - size_t i; > + virGICVersion version; > > if (domCaps->arch != VIR_ARCH_ARMV7L && > domCaps->arch != VIR_ARCH_AARCH64) > @@ -4291,20 +4334,17 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps, > !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)) > + for (version = VIR_GIC_VERSION_LAST - 1; > + version > VIR_GIC_VERSION_NONE; > + version--) { > + if (!virQEMUCapsSupportsGICVersion(qemuCaps, > + domCaps->virttype, > + version)) > continue; > > gic->supported = true; > VIR_DOMAIN_CAPS_ENUM_SET(gic->version, > - cap->version); > + version); > } > > return 0; > diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h > index e7d0a60..fef78b7 100644 > --- a/src/qemu/qemu_capabilities.h > +++ b/src/qemu/qemu_capabilities.h > @@ -462,6 +462,10 @@ bool virQEMUCapsSupportsChardev(const virDomainDef *def, > virQEMUCapsPtr qemuCaps, > virDomainChrDefPtr chr); > > +bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps, > + virDomainVirtType virtType, > + virGICVersion version); > + > bool virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps, > const char *canonical_machine); > > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list