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

Re: [libvirt] [PATCHv2 15/21] conf: Add separate defaults addition and validation for XML parsing



On 06.03.2013 16:37, Peter Krempa wrote:
> This patch adds instrumentation that will ultimately allow to split out
> filling of defaults and input validation from the XML parser to separate
> functions.
> 
> With this patch, after the XML is parsed, a callback to the driver is
> issued requesing to fill and validate driver specific details of the
> configuration. This allows to use sensible defaults and checks on a per
> driver basis at the time the XML is parsed.
> 
> Three callback pointers are exposed in the new virDomainXMLConf object:
> * virDeviceDefAdjustCallback - called for a single device parsed and
>                                for every single device in a domain
>                                config. A virDomainDeviceDefPtr is
>                                passed along with the domain
>                                definition and virCaps.

s/virDeviceDefAdjustCallback/virDomainDeviceDefAdjustCallback/

> * virDomainDefAdjustCallback - called if a domain definition is parsed
>                                device specific callbacks were called.
>                                A virDomainDefPtr is passed along with
>                                virCaps. There are two callbacks of this
>                                kind, one called before the devices are
>                                parsed and one after.
> 
> Errors may be reported in those callbacks resulting in a XML parsing
> failure.
> 
> Additionally internal filler and checker functions are added that are
> meant to be used forseparating the validation and defaults assignment
> code from the parser function.
> ---
>  src/conf/domain_conf.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  src/conf/domain_conf.h |  14 +++++++
>  2 files changed, 120 insertions(+), 2 deletions(-)
> 

> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 4ec3e0b..15d9838 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1937,6 +1937,20 @@ typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
>  typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
>  typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);
> 
> +typedef int (*virDomainDefAdjustCallback)(virDomainDefPtr def,
> +                                          virCapsPtr caps);
> +typedef int (*virDomainDeviceDefAdjustCallback)(virDomainDeviceDefPtr dev,
> +                                               virDomainDefPtr def,
> +                                               virCapsPtr caps);
> +
> +typedef struct _virDomainDefAdjustCallbacks virDomainDefAdjustCallbacks;
> +typedef virDomainDefAdjustCallbacks *virDomainDefAdjustCallbacksPtr;
> +struct _virDomainDefAdjustCallbacks {
> +    virDomainDefAdjustCallback domainBeforeDevices;
> +    virDomainDeviceDefAdjustCallback devices;
> +    virDomainDefAdjustCallback domainAfterDevices;
> +};
> +
>  typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
>  typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
>  struct _virDomainXMLPrivateDataCallbacks {
> 


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