On 05/10/2016 08:46 AM, Andrea Bolognani wrote: > Now that we choose the GIC version based on hardware features when > no <gic/> element has been provided, we need a way to fake the GIC > capabilities of the host. > > Update the qemuxml2argv and qemuxml2xml tests to allow this. > --- > tests/qemuxml2argvtest.c | 77 ++++++++++++++++++----- > tests/qemuxml2xmltest.c | 159 ++++++++++++++++++++++++++++------------------- > 2 files changed, 159 insertions(+), 77 deletions(-) > > diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c > index e41444d..b081634 100644 > --- a/tests/qemuxml2argvtest.c > +++ b/tests/qemuxml2argvtest.c > @@ -34,6 +34,13 @@ > static const char *abs_top_srcdir; > static virQEMUDriver driver; > > +enum { > + GIC_NONE = 0, > + GIC_V2, > + GIC_V3, > + GIC_BOTH, > +}; > + > static unsigned char * > fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED, > size_t *value_size, > @@ -452,6 +459,49 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy) > > > static int > +testPrepareExtraFlags(struct testInfo *info, > + bool skipLegacyCPUs, > + int gic) > +{ > + virGICCapability *gicCapabilities = NULL; > + size_t ngicCapabilities = 0; > + int ret = -1; > + > + if (!(info->extraFlags = virQEMUCapsNew())) > + goto out; > + > + if (testAddCPUModels(info->extraFlags, skipLegacyCPUs) < 0) > + goto out; > + > + if (VIR_ALLOC_N(gicCapabilities, 2) < 0) > + goto out; > + > +# define IMPL_BOTH \ > + VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED > + > + if (gic & GIC_V2) { > + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_2; > + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; > + ngicCapabilities++; > + } > + if (gic & GIC_V3) { > + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_3; > + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; > + ngicCapabilities++; > + } > + > +# undef IMPL_BOTH > + > + virQEMUCapsSetGICCapabilities(info->extraFlags, > + gicCapabilities, ngicCapabilities); > + > + ret = 0; > + > + out: > + return ret; > +} Can this logic be shared in a testutilsqemu.c function, rather than duplicated across both test files? - Cole -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list