[libvirt] [PATCHv2 20/21] conf: Move validation of domain title

Michal Privoznik mprivozn at redhat.com
Thu Mar 7 16:35:33 UTC 2013


On 06.03.2013 16:38, Peter Krempa wrote:
> Use the helper to avoid doing this in the parser.
> ---
>  src/conf/domain_conf.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 0432483..d68e30a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2466,10 +2466,15 @@ virDomainDeviceDefAdjustInternal(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
> 
> 
>  static int
> -virDomainDefAdjustInternal(virDomainDefPtr def ATTRIBUTE_UNUSED,
> +virDomainDefAdjustInternal(virDomainDefPtr def,
>                             virCapsPtr caps ATTRIBUTE_UNUSED)
>  {
> -    /* not in use yet */
> +    /* verify the domain title */
> +    if (def->title && strchr(def->title, '\n')) {
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("Domain title can't contain newlines"));
> +        return -1;
> +    }
>      return 0;
>  }
> 
> @@ -9485,12 +9490,6 @@ virDomainDefParseXML(virCapsPtr caps,
> 
>      /* Extract short description of domain (title) */
>      def->title = virXPathString("string(./title[1])", ctxt);
> -    if (def->title && strchr(def->title, '\n')) {
> -        virReportError(VIR_ERR_XML_ERROR, "%s",
> -                       _("Domain title can't contain newlines"));
> -        goto error;
> -    }
> -
>      /* Extract documentation if present */
>      def->description = virXPathString("string(./description[1])", ctxt);
> 

This should be rather in next patch. However, it is nice how-to use
this. But please, move it to virDomainDefVerifyInternal().




More information about the libvir-list mailing list