Re: [PATCH 2/8] Introduce new virDomainNormalizeXML API

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

 



On 09/17/2013 08:46 AM, Michal Privoznik wrote:
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]