Re: [PATCH v6 5/5] Network: Add support for DNS hosts definition to the network XML

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

 



On Fri, Jun 24, 2011 at 12:04:40PM +0200, Michal Novotny wrote:
> This commit introduces names definition for the DNS hosts file using
> the following syntax:
> 
>   <dns>
>     <host ip="192.168.1.1">
>       <name>alias1</name>
>       <name>alias2</name>
>     </host>
>   </dns>
> 
> Some of the improvements and fixes were done by Laine Stump so
> I'm putting him into the SOB clause again ;-)
> 
> Signed-off-by: Michal Novotny <minovotn@xxxxxxxxxx>
> Signed-off-by: Laine Stump <lstump@xxxxxxxxxx>
[...]
> +    cur = node->children;
> +    while (cur != NULL) {
> +        if (cur->type == XML_ELEMENT_NODE &&
> +            xmlStrEqual(cur->name, BAD_CAST "hostname")) {
> +              if (cur->children != NULL) {
> +                  if (VIR_REALLOC_N(def->hosts[def->nhosts].names, def->hosts[def->nhosts].nnames + 1) < 0) {
> +                      virReportOOMError();
> +                      goto error;
> +                  }
> +
> +                  def->hosts[def->nhosts].names[def->hosts[def->nhosts].nnames] = strdup((char *)cur->children->content);
> +                  def->hosts[def->nhosts].nnames++;
> +              }
> +        }
> +
> +        cur = cur->next;
> +    }

  I would suggest to clean this up, as a separate patch to use a
XPath nodeset query for hostname, and then use xmlNodeGetContent()
to get the content string instead of trying to poke at
cur->children->content (which may broke in some weird cases)

Daniel


-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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