On Fri, Oct 13, 2017 at 08:14 PM +0200, Jiri Denemark <jdenemar@xxxxxxxxxx> wrote: > When a hypervisor marks a CPU model as unusable on the current host, it > may also give us a list of features which prevent the model from being > usable. Storing this list in virDomainCapsCPUModel will help the CPU > driver with creating a host-model CPU configuration. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx> > --- > > Notes: > Version 2: > - no change > > src/conf/domain_capabilities.c | 30 ++++++++++++++++++++++-------- > src/conf/domain_capabilities.h | 7 +++++-- > src/qemu/qemu_capabilities.c | 11 ++++++----- > tests/domaincapstest.c | 6 +++--- > 4 files changed, 36 insertions(+), 18 deletions(-) > > diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c > index f62038b96c..be34576204 100644 > --- a/src/conf/domain_capabilities.c > +++ b/src/conf/domain_capabilities.c > @@ -163,7 +163,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old) > for (i = 0; i < old->nmodels; i++) { > if (virDomainCapsCPUModelsAdd(cpuModels, > old->models[i].name, -1, > - old->models[i].usable) < 0) > + old->models[i].usable, > + old->models[i].blockers) < 0) > goto error; > } > > @@ -195,7 +196,8 @@ virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old, > > if (virDomainCapsCPUModelsAdd(cpuModels, > old->models[i].name, -1, > - old->models[i].usable) < 0) > + old->models[i].usable, > + old->models[i].blockers) < 0) > goto error; > } > > @@ -210,7 +212,8 @@ virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr old, > int > virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > char **name, > - virDomainCapsCPUUsable usable) > + virDomainCapsCPUUsable usable, > + char ***blockers) > { > if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, > cpuModels->nmodels, 1) < 0) > @@ -218,6 +221,10 @@ virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > > cpuModels->models[cpuModels->nmodels].usable = usable; > VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].name, *name); > + > + if (blockers) > + VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].blockers, *blockers); > + > cpuModels->nmodels++; > return 0; > } > @@ -227,20 +234,27 @@ int > virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, > const char *name, > ssize_t nameLen, > - virDomainCapsCPUUsable usable) > + virDomainCapsCPUUsable usable, > + char **blockers) > { > - char *copy = NULL; > + char *nameCopy = NULL; > + char **blockersCopy = NULL; > > - if (VIR_STRNDUP(copy, name, nameLen) < 0) > + if (VIR_STRNDUP(nameCopy, name, nameLen) < 0) > goto error; > > - if (virDomainCapsCPUModelsAddSteal(cpuModels, ©, usable) < 0) > + if (virStringListCopy(&blockersCopy, (const char **)blockers) < 0) > + goto error; > + > + if (virDomainCapsCPUModelsAddSteal(cpuModels, &nameCopy, > + usable, &blockersCopy) < 0) > goto error; > > return 0; > > error: > - VIR_FREE(copy); > + VIR_FREE(nameCopy); > + virStringListFree(blockersCopy); > return -1; > } > > diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h > index 82183c4524..8c71dec21e 100644 > --- a/src/conf/domain_capabilities.h > +++ b/src/conf/domain_capabilities.h > @@ -116,6 +116,7 @@ typedef virDomainCapsCPUModel *virDomainCapsCPUModelPtr; > struct _virDomainCapsCPUModel { > char *name; > virDomainCapsCPUUsable usable; > + char **blockers; /* NULL-terminated list of usability blockers */ > }; I know this is an "old" thread and already pushed. But I think you have to free the blockers list in virDomainCapsCPUModelsDispose as well. No? > > typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels; > @@ -171,11 +172,13 @@ virDomainCapsCPUModelsPtr virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr > const char **blacklist); > int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > char **name, > - virDomainCapsCPUUsable usable); > + virDomainCapsCPUUsable usable, > + char ***blockers); > int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, > const char *name, > ssize_t nameLen, > - virDomainCapsCPUUsable usable); [...snip] -- Beste Grüße / Kind regards Marc Hartmayer IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list