[libvirt] [PATCH] 2/4 Add conf parsing and freeing

Eric Blake eblake at redhat.com
Thu Oct 21 21:45:40 UTC 2010


On 10/21/2010 02:16 PM, Daniel Veillard wrote:
>   This lacks the saving of the smbios data, should not be hard really,
> and the parsing is rather trivial, the data structures follow the XML
> format:
>
> Daniel
>
>
> +static void virSmbiosEntriesFree(virSmbiosEntryPtr cur)

Should this function be added to the list of useless_free_options in cfg.mk?

> +{
> +    virSmbiosEntryPtr next;
> +
> +    if (cur == NULL)
> +        return;

Redundant, given that

> +
> +    while (cur != NULL) {

this safely skips a NULL argument.

> @@ -3341,6 +3385,150 @@ error:
>       goto cleanup;
>   }
>
> +static virSmbiosEntryPtr
> +virSmbiosEntryParseXML(xmlXPathContextPtr ctxt)
> +{
> +    char *name, *value;
> +    virSmbiosEntryPtr def;
> +
> +    name = virXPathString("string(./@name)", ctxt);
> +    if (name == NULL) {
> +        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
> +                  _("XML element 'entry' requires a 'name' attrbute"));

s/attrbute/attribute/

> +
> +static virSmbiosBlockPtr
> +virSmbiosBlockParseXML(xmlXPathContextPtr ctxt)
> +{
> +    virSmbiosBlockPtr def;
> +    virSmbiosEntryPtr cur, next;
> +    xmlNodePtr *nodes = NULL;
> +    int n;
> +    unsigned int i;
> +    long type;
> +
> +    if (virXPathLong("string(./@type)", ctxt,&type)<  0) {
> +        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
> +                  _("XML element 'table' requires a numeric 'type' attrbute"));

s/attrbute/attribute/

> +        return(NULL);
> +    }
> +    if ((type<  0) || (type>  32)) {
> +        virDomainReportError(VIR_ERR_XML_ERROR,
> +              _("XML 'type' attribute on 'table' out of 0..32 range got %ld"),
> +                type);
> +        return(NULL);
> +    }

Should you also be checking for duplicate types, or is it okay to do:

   <smbios>
     <table type="0">
       <entry name="Vendor">QEmu/KVM</entry>
     </table>
     <table type="0">
       <entry name="Version">0.13</entry>
     </table>
   </smbios>

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list