[libvirt] [PATCH 1/4] cpu: allow include files for CPU definition

Daniel P. Berrangé berrange at redhat.com
Thu Aug 16 10:16:09 UTC 2018


On Tue, Aug 14, 2018 at 12:55:19PM +0200, Jiri Denemark wrote:
> On Wed, Aug 01, 2018 at 18:02:29 +0100, Daniel P. Berrangé wrote:
> > Allow for syntax
> > 
> >     <include filename="fooo.xml"/>
> 
> It seems the code should just work with
> 
>     <include filename="cpu_map/arch_foo.xml"/>
> 
> but Makefile.am and libvirt.spec would need some adjustment.
> 
> > to reference other files in the CPU database directory
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> > ---
> >  libvirt.spec.in       |  2 +-
> >  mingw-libvirt.spec.in |  4 +--
> >  src/Makefile.am       |  2 +-
> >  src/cpu/cpu_map.c     | 84 +++++++++++++++++++++++++++++++++++++++++--
> >  4 files changed, 86 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libvirt.spec.in b/libvirt.spec.in
> > index 19ae55cdaf..b6745dbffa 100644
> > --- a/libvirt.spec.in
> > +++ b/libvirt.spec.in
> > @@ -1856,7 +1856,7 @@ exit 0
> >  %{_datadir}/libvirt/schemas/storagepool.rng
> >  %{_datadir}/libvirt/schemas/storagevol.rng
> >  
> > -%{_datadir}/libvirt/cpu_map.xml
> > +%{_datadir}/libvirt/cpu_map*.xml
> >  
> >  %{_datadir}/libvirt/test-screenshot.png
> >  
> > diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
> > index cc1e619927..22fe7a000f 100644
> > --- a/mingw-libvirt.spec.in
> > +++ b/mingw-libvirt.spec.in
> > @@ -260,7 +260,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
> >  %{mingw32_datadir}/libvirt/api/libvirt-qemu-api.xml
> >  %{mingw32_datadir}/libvirt/api/libvirt-admin-api.xml
> >  
> > -%{mingw32_datadir}/libvirt/cpu_map.xml
> > +%{mingw32_datadir}/libvirt/cpu_map*.xml
> >  
> >  %{mingw32_datadir}/libvirt/test-screenshot.png
> >  
> > @@ -347,7 +347,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
> >  %{mingw64_datadir}/libvirt/api/libvirt-qemu-api.xml
> >  %{mingw64_datadir}/libvirt/api/libvirt-admin-api.xml
> >  
> > -%{mingw64_datadir}/libvirt/cpu_map.xml
> > +%{mingw64_datadir}/libvirt/cpu_map*.xml
> >  
> >  %{mingw64_datadir}/libvirt/test-screenshot.png
> >  
> > diff --git a/src/Makefile.am b/src/Makefile.am
> > index a4f213480e..11a7ac81e2 100644
> > --- a/src/Makefile.am
> > +++ b/src/Makefile.am
> > @@ -366,7 +366,7 @@ check-local: check-protocol check-symfile check-symsorting \
> >  
> >  
> >  
> > -pkgdata_DATA =	cpu/cpu_map.xml
> > +pkgdata_DATA =	$(wildcard $(srcdir)/cpu/cpu_map*.xml)
> >  
> >  EXTRA_DIST +=	$(pkgdata_DATA)
> >  
> > diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
> > index d263eb8cdd..9e090919ed 100644
> > --- a/src/cpu/cpu_map.c
> > +++ b/src/cpu/cpu_map.c
> > @@ -70,6 +70,83 @@ static int load(xmlXPathContextPtr ctxt,
> ..
> > +static int loadIncludes(xmlXPathContextPtr ctxt,
> > +                        cpuMapLoadCallback callback,
> > +                        void *data)
> > +{
> > +    int ret = -1;
> > +    xmlNodePtr ctxt_node;
> > +    xmlNodePtr *nodes = NULL;
> > +    int n;
> > +    size_t i;
> > +
> > +    ctxt_node = ctxt->node;
> > +
> > +    n = virXPathNodeSet("include", ctxt, &nodes);
> > +    if (n < 0)
> > +        goto cleanup;
> > +
> > +    for (i = 0; i < n; i++) {
> > +        char *filename = virXMLPropString(nodes[i], "filename");
> 
> This would be a nice candidate for VIR_AUTOFREE(char *) :-)

Since none of the src/cpu code has been switched to this style yet, its
probably best not to introduce it here. Rather wait for the bulk convert


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list