On 08/12/2016 09:33 AM, Jiri Denemark wrote: > Listing all CPU models supported by QEMU in domain capabilities makes > little sense when libvirt will refuse any model it doesn't know about. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > src/conf/domain_capabilities.c | 27 ++ > src/conf/domain_capabilities.h | 2 + > src/libvirt_private.syms | 1 + > src/qemu/qemu_capabilities.c | 10 +- > tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml | 428 ---------------------- > 5 files changed, 39 insertions(+), 429 deletions(-) > > diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c > index c07f995..6f9f7e7 100644 > --- a/src/conf/domain_capabilities.c > +++ b/src/conf/domain_capabilities.c > @@ -169,6 +169,33 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old) > } > > > +virDomainCapsCPUModelsPtr > +virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old, > + char **models) > +{ > + virDomainCapsCPUModelsPtr cpuModels; > + size_t i; > + > + if (!(cpuModels = virDomainCapsCPUModelsNew(0))) > + return NULL; > + > + for (i = 0; i < old->count; i++) { > + if (models && !virStringArrayHasString(models, old->models[i].name)) My Coverity environment had a build failure here: conf/domain_capabilities.c: In function 'virDomainCapsCPUModelsFilter': conf/domain_capabilities.c:183:48: error: passing argument 1 of 'virStringArrayHasString' from incompatible pointer type [-Werror=incompatible-pointer-types] if (models && !virStringArrayHasString(models, old->models[i].name)) ^~~~~~ In file included from conf/domain_capabilities.c:28:0: ./util/virstring.h:47:6: note: expected 'const char **' but argument is of type 'char **' bool virStringArrayHasString(const char **strings, const char *needle); ^~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Makefile:8092: recipe for target 'conf/libvirt_conf_la-domain_capabilities.lo' failed Which a handily place (const char **) resolved. I seem to recall a discussion on something similar recently upstream... > + continue; > + > + if (virDomainCapsCPUModelsAdd(cpuModels, > + old->models[i].name, -1) < 0) > + goto error; > + } > + > + return cpuModels; > + > + error: > + virObjectUnref(cpuModels); > + return NULL; > +} > + > + > int > virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > char **name) > diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h > index 509c306..29b18bb 100644 > --- a/src/conf/domain_capabilities.h > +++ b/src/conf/domain_capabilities.h > @@ -156,6 +156,8 @@ virDomainCapsPtr virDomainCapsNew(const char *path, > > virDomainCapsCPUModelsPtr virDomainCapsCPUModelsNew(size_t nmodels); > virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old); > +virDomainCapsCPUModelsPtr virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old, > + char **models); > int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > char **name); > int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index f91ce17..80c112a 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -155,6 +155,7 @@ virDomainAuditVcpu; > virDomainCapsCPUModelsAdd; > virDomainCapsCPUModelsAddSteal; > virDomainCapsCPUModelsCopy; > +virDomainCapsCPUModelsFilter; > virDomainCapsCPUModelsNew; > virDomainCapsEnumClear; > virDomainCapsEnumSet; > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index 7a7ddb8..123aae5 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -4198,6 +4198,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps, > virQEMUCapsPtr qemuCaps, > virDomainCapsPtr domCaps) > { > + virDomainCapsCPUModelsPtr filtered = NULL; > + char **models = NULL; > > if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM && > virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch)) > @@ -4207,7 +4209,13 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps, > domCaps->cpu.hostModel = virQEMUCapsGuestIsNative(caps->host.arch, > qemuCaps->arch); > > - domCaps->cpu.custom = virObjectRef(qemuCaps->cpuDefinitions); > + if (qemuCaps->cpuDefinitions && > + cpuGetModels(domCaps->arch, &models) >= 0) { if cpuGetModels returns 0, then models is empty so is there any point in making the call? > + filtered = virDomainCapsCPUModelsFilter(qemuCaps->cpuDefinitions, > + models); > + virStringFreeList(models); > + } > + domCaps->cpu.custom = filtered; > > return 0; > } [...] -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list