[libvirt] [PATCH 03/10] Add namespace callback hooks to domain_conf.

Daniel P. Berrange berrange at redhat.com
Thu Apr 22 11:59:45 UTC 2010


On Wed, Apr 21, 2010 at 12:01:17PM -0400, Chris Lalancette wrote:
> This patch adds namespace XML parsers to be hooked into
> the main domain parser.  This allows for individual hypervisor
> drivers to add per-namespace XML into the main domain XML.
> 
> Signed-off-by: Chris Lalancette <clalance at redhat.com>
> ---
>  src/conf/capabilities.c |    2 ++
>  src/conf/capabilities.h |   17 +++++++++++++++++
>  src/conf/domain_conf.c  |   44 +++++++++++++++++++++++++++++++++++++-------
>  src/conf/domain_conf.h  |    3 +++
>  4 files changed, 59 insertions(+), 7 deletions(-)
> 
> diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
> index dafd821..d4a6070 100644
> --- a/src/conf/capabilities.c
> +++ b/src/conf/capabilities.c
> @@ -174,6 +174,8 @@ virCapabilitiesFree(virCapsPtr caps) {
>      VIR_FREE(caps->host.secModel.doi);
>      virCPUDefFree(caps->host.cpu);
>  
> +    VIR_FREE(caps->ns);
> +
>      VIR_FREE(caps);
>  }

I'm inclined to say caps->ns can just be a pointer to a statically
declared table as we with for the main driver function tables,
avoiding need to free it.

> @@ -4366,6 +4372,22 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
>              goto error;
>      }
>  
> +    /* callout to per-namespace parsers (in the individual drivers) */
> +    if (caps->ns) {
> +        /* we have to make a copy of all of the callback pointers here since
> +         * we won't have the virCaps structure available during free
> +         */
> +        def->ns.parse = caps->ns->parse;
> +        def->ns.free = caps->ns->free;
> +        def->ns.format = caps->ns->format;
> +        def->ns.href = caps->ns->href;
> +
> +        if (def->ns.parse) {
> +            if ((def->ns.parse)(xml, root, ctxt, &def->namespaceData) < 0)
> +                goto error;
> +        }
> +    }

If we're using the static driver tables, we can just use a plain assignment
here like    'def->ns = caps->ns"


Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list