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

Eric Blake eblake at redhat.com
Wed Apr 21 17:01:18 UTC 2010


On 04/21/2010 10:01 AM, 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.

> 
> @@ -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;

Can these four lines be simplified as: def->ns = *caps->ns

> +    if (def->namespaceData && def->ns.href)
> +        virBufferVSprintf(&buf, " %s", (def->ns.href)());

Are we guaranteed that def->namespaceData will be non-null if ns.parse
succeeded, or should we call ns.href if present even if
def->namespaceData is NULL?

> +    if (def->namespaceData && def->ns.format) {
> +        if ((def->ns.format)(&buf, def->namespaceData) < 0)

Likewise - can ns.format exist, but namespaceData validly be NULL after
a successful ns.parse?

If ns.parse is required to set namespaceData to a non-NULL value on
success, then ACK.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100421/a38fe4bb/attachment-0001.sig>


More information about the libvir-list mailing list