[libvirt] [PATCH v2 02/10] conf: Add infrastructure for adding configuration validation
Pavel Hrdina
phrdina at redhat.com
Tue Jun 7 07:12:22 UTC 2016
On Fri, May 27, 2016 at 02:21:51PM +0200, Peter Krempa wrote:
> Until now we weren't able to add checks would reject configuration once
s/checks would/check that would
> accepted by the parser. This patch adds a new callback and
> infrastructure to add such checks. In this patch all the places where
> rejecting a now-invalid configuration wouldn't be a good idea are marked
> with a new parser flag.
> ---
> src/conf/domain_conf.c | 48 ++++++++++++++++++++++++++++++++++++++++++-
> src/conf/domain_conf.h | 16 +++++++++++++++
> src/conf/snapshot_conf.c | 3 ++-
> src/conf/virdomainobjlist.c | 6 ++++--
> src/libvirt_private.syms | 1 +
> src/libxl/libxl_domain.c | 3 ++-
> src/libxl/libxl_migration.c | 6 ++++--
> src/openvz/openvz_driver.c | 3 ++-
> src/qemu/qemu_domain.c | 3 ++-
> src/qemu/qemu_driver.c | 9 +++++---
> src/qemu/qemu_migration.c | 12 +++++++----
> src/security/virt-aa-helper.c | 3 ++-
> 12 files changed, 96 insertions(+), 17 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index e2e247a..d6bd737 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -4540,6 +4540,47 @@ virDomainDefPostParse(virDomainDefPtr def,
> }
>
>
> +static int
> +virDomainDefValidateInternal(const virDomainDef *def ATTRIBUTE_UNUSED)
> +{
> + return 0;
> +}
> +
> +
> +/**
> + * virDomainDefValidate:
> + * @def: domain definition
You're missing the rest o the parameters.
> + *
> + * This validation function is designed to take checks of globally invalid
> + * configurations that the parser needs to accept so that VMs don't vanish upon
> + * daemon restart. Such definition can be rejected upon startup or define, where
> + * this function shall be called.
> + *
> + * Returns 0 if domain definition is valid, -1 on error and reports an
> + * appropriate message.
> + */
> +int
> +virDomainDefValidate(const virDomainDef *def,
> + virCapsPtr caps,
> + unsigned int parseFlags,
> + virDomainXMLOptionPtr xmlopt)
> +{
> + /* validate configuration only in certain places */
> + if (parseFlags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)
> + return 0;
> +
> + /* call the domain config callback */
> + if (xmlopt->config.domainValidateCallback &&
> + xmlopt->config.domainValidateCallback(def, caps, xmlopt->config.priv) < 0)
> + return -1;
> +
> + if (virDomainDefValidateInternal(def) < 0)
> + return -1;
> +
> + return 0;
> +}
ACK with the defects fixed.
More information about the libvir-list
mailing list