On 08/12/2016 09:32 AM, Jiri Denemark wrote: > The patch adds <cpu> element to domain capabilities XML: > > <cpu> > <mode name='host-passthrough' supported='yes'/> > <mode name='host-model' supported='yes'/> > <mode name='custom' supported='yes'> > <model>Broadwell</model> > <model>Broadwell-noTSX</model> > ... > </mode> > </cpu> > > Applications can use it to inspect what CPU configuration modes are > supported for a specific combination of domain type, emulator binary, > guest architecture and machine type. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > docs/formatdomaincaps.html.in | 44 ++++++ > docs/schemas/domaincaps.rng | 43 ++++++ > src/conf/domain_capabilities.c | 150 +++++++++++++++++++++ > src/conf/domain_capabilities.h | 33 +++++ > src/libvirt_private.syms | 4 + > tests/domaincapsschemadata/basic.xml | 5 + > tests/domaincapsschemadata/full.xml | 9 ++ > tests/domaincapsschemadata/libxl-xenfv-usb.xml | 5 + > tests/domaincapsschemadata/libxl-xenfv.xml | 5 + > tests/domaincapsschemadata/libxl-xenpv-usb.xml | 5 + > tests/domaincapsschemadata/libxl-xenpv.xml | 5 + > tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml | 5 + > .../qemu_2.6.0-gicv2-virt.aarch64.xml | 5 + > .../qemu_2.6.0-gicv3-virt.aarch64.xml | 5 + > tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml | 5 + > tests/domaincapsschemadata/qemu_2.6.0.ppc64le.xml | 5 + > tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml | 5 + > tests/domaincapstest.c | 9 ++ > 18 files changed, 347 insertions(+) [...] > diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c > index 1676f0e..c07f995 100644 > --- a/src/conf/domain_capabilities.c > +++ b/src/conf/domain_capabilities.c [...] > + > +int > +virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, > + char **name) > +{ > + if (VIR_RESIZE_N(cpuModels->models, cpuModels->alloc, > + cpuModels->count, 1) < 0) > + return -1; > + > + cpuModels->models[cpuModels->count++].name = *name; > + *name = NULL; Similar to VIR_STEAL_PTR with the added count++ twist... > + return 0; > +} > + > + > +int > +virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, > + const char *name, > + ssize_t nameLen) > +{ > + char *copy = NULL; > + > + if (VIR_STRNDUP(copy, name, nameLen) < 0) > + goto error; > + > + if (virDomainCapsCPUModelsAddSteal(cpuModels, ©) < 0) > + goto error; > + > + return 0; > + > + error: > + VIR_FREE(copy); > + return -1; > +} > + > + > int > virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, > const char *capsEnumName, > @@ -234,6 +338,51 @@ virDomainCapsOSFormat(virBufferPtr buf, > } > > static void [...] > diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h > index 492a9cf..509c306 100644 > --- a/src/conf/domain_capabilities.h > +++ b/src/conf/domain_capabilities.h > @@ -102,6 +102,30 @@ struct _virDomainCapsFeatureGIC { > virDomainCapsEnum version; /* Info about virGICVersion */ > }; > > +typedef struct _virDomainCapsCPUModel virDomainCapsCPUModel; > +typedef virDomainCapsCPUModel *virDomainCapsCPUModelPtr; > +struct _virDomainCapsCPUModel { > + char *name; > +}; > + > +typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels; > +typedef virDomainCapsCPUModels *virDomainCapsCPUModelsPtr; > +struct _virDomainCapsCPUModels { > + virObject parent; > + > + size_t alloc; > + size_t count; Easier for me to read/see "->nmodels_max" and "->nmodels"... Not sure how pervasive it is to change... Not a requirement, your call... > + virDomainCapsCPUModelPtr models; > +}; > + > +typedef struct _virDomainCapsCPU virDomainCapsCPU; > +typedef virDomainCapsCPU *virDomainCapsCPUPtr; > +struct _virDomainCapsCPU { > + bool hostPassthrough; > + bool hostModel; > + virDomainCapsCPUModelsPtr custom; > +}; > + [...] -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list