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

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

 



On 18.09.2013 17:50, Eric Blake wrote:
> 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.
> 

Right, however, some of our device parsing functions require
virDomainDefPtr (or some parts of it), for instance
virDomainDiskDefParseXML(). To get rid of that would mean much more changes.

Speaking of which, I think the better approach would be to split parse
and check of XML into two separate steps. Or in fact three steps: parse,
fill in defaults, sanity check.

Michal

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