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

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

 



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().

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