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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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 *) :-)

> +        VIR_DEBUG("Finding CPU map include '%s'", filename);
> +        if (cpuMapLoadInclude(filename, callback, data) < 0) {
> +            VIR_FREE(filename);
> +            goto cleanup;
> +        }
> +        VIR_FREE(filename);
> +    }

Jirka

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux