[libvirt] [PATCH 2/8] Introduce new virDomainNormalizeXML API

Eric Blake eblake at redhat.com
Wed Sep 18 15:50:23 UTC 2013


On 09/17/2013 08:46 AM, Michal Privoznik wrote:
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  include/libvirt/libvirt.h.in    |  5 ++++
>  python/generator.py             |  1 +
>  python/libvirt-override-api.xml |  7 ++++++
>  python/libvirt-override.c       | 30 ++++++++++++++++++++++++
>  src/driver.h                    |  7 ++++++
>  src/libvirt.c                   | 51 +++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms         |  5 ++++
>  7 files changed, 106 insertions(+)
> 

> +
> +/**
> + * virDomainNormalizeXML:
> + * @domain: a domain object
> + * @xmlIn: XML to normalize
> + * @xmlOut: the result of normalization
> + * @flags: bitwise-OR of subset of virDomainXMLFlags
> + *
> + * Intruct libvirt to take @xmlIn, parse it and format again. This has effect

s/Intruct/Instruct/

> + * that all returned values are formated as they would be a part of @dom. For

s/formated/formatted/

> + * example, if among passed @xmlIn and address='0x00008' occurs, it is
> + * formatted as address='0x08'. The result of normalization is returned in @xmlOut
> + * (automatically allocated array which is supposed to be freed by caller once
> + * no longer needed). However, if only validation of @xmlIn is desired, pass
> + * NULL as @xmlOut.
> + *
> + * Returns 0 on success -1 otherwise.
> + */
> +int
> +virDomainNormalizeXML(virDomainPtr domain,
> +                      const char *xmlIn,
> +                      char **xmlOut,
> +                      unsigned int flags)

When the topic came up in the past, the question was whether we can ALSO
use this API to do systematic RelaxNG validation of the input xml (where
xmlOut can be NULL if only validation is required, or a non-NULL pointer
to also get the normalized result on success; or an error if validation
fails).  Of course, RelaxNG validation should be specified via flags
(and not done all the time).

Meanwhile, I'm not sure this is quite the right interface.  When this
topic came up last time, I had mentioned the idea of having it be
virConnectNormalizeXML(virConnectPtr conn, int type, const char *xmlIn,
char **xmlOut, unsigned int flags), where 'type' is an enum that says
WHAT type of XML is being normalized (<domain>, a <disk> sub-element of
domain, <network>, <domainsnapshot>, <nwfilter>, etc).  In particular,
since device hot-plug uses a subset of domain, it might be nice to
support the normalization of a disk hotplug snippet without having to
plug it into a larger <domain> XML - possible if we have an enum that
tells the API which (subset of) schema we are targetting.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list