On 02/21/2013 07:47 AM, Peter Krempa wrote:
> This patch adds basic configuration support for the RNG device suporting

s/suporting/supporting/

> the virtio model with the "random" and "egd" backend types as described
> in the schema in the previous patch.
> ---
> 
> Notes:
>     Version 2:
>     - fix a ton of memory leaks (I assumed that virXMLGetProp returns static 
> strings)
>     - Add new device type to even more places
>     - Fix error message c&p error
>     - Fix memleak in RNGDef free func

> +    case VIR_DOMAIN_RNG_BACKEND_EGD:
> +        {
> +            char *type = virXMLPropString(backends[0], "type");
> +            if (!type) {
> +                virReportError(VIR_ERR_XML_ERROR, "%s",
> +                               _("missing EGD backend type"));
> +                goto error;
> +            }
> +
> +
> +            if (VIR_ALLOC(def->source.chardev) < 0) {
> +                virReportOOMError();
> +                goto error;
> +            }

Memleak on 'type'.

> @@ -10601,6 +10734,22 @@ virDomainDefParseXML(virCapsPtr caps,
>          }
>      }
> 
> +    /* Parse the RNG device */
> +    if ((n = virXPathNodeSet("./devices/rng", ctxt, &nodes)) < 0)
> +        goto error;
> +
> +    if (n > 1) {
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("only a single RNG device is supported"));

Is this an inherent limit of qemu?  For that matter, is it an inherent
limit, and no hypervisor can ever support more than one?  In the bare
metal case, can't you plug in multiple rng hardware dongles?


> +static int
> +virDomainRNGDefFormat(virBufferPtr buf,
> +                      virDomainRNGDefPtr def,
> +                      unsigned int flags)
> +{
> +    const char *model = virDomainRNGModelTypeToString(def->model);
> +    const char *backend = virDomainRNGBackendTypeToString(def->backend);
> +
> +    virBufferAsprintf(buf, "    <rng model='%s'>\n", model);
> +    virBufferAsprintf(buf, "      <backend model='%s'", backend);
> +
> +    switch ((enum virDomainRNGBackend) def->backend) {
> +    case VIR_DOMAIN_RNG_BACKEND_RANDOM:
> +        if (def->source.file)
> +            virBufferAsprintf(buf, ">%s</backend>\n", def->source.file);

Must use virBufferEscape(), as a random file name could contain
characters that are special to XML.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to