[libvirt] [PATCH 05/18] domain_conf: split graphics xml parser into multiple functions

Ján Tomko jtomko at redhat.com
Wed Apr 6 15:43:07 UTC 2016


On Mon, Apr 04, 2016 at 03:20:22PM +0200, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  src/conf/domain_conf.c | 835 +++++++++++++++++++++++++++----------------------
>  1 file changed, 453 insertions(+), 382 deletions(-)
> 

s/ParseXMLVnc/ParseXMLVNC/g
s/ParseXMLSdl/ParseXMLSDL/g
s/ParseXMLRdp/ParseXMLRDP/g

would IMO look nicer.

> +
> +    if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                       _("unknown graphics device type '%s'"), type);
> +        goto error;
> +    }
> +
> +    if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
> +        goto error;
> +
> +    switch (def->type) {

You could also cast the type to the enum, to annoy anyone adding a new
graphics type to add it to this switch too.

ACK

Jan

> +    case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
> +        if (virDomainGraphicsDefParseXMLVnc(def, node, flags) < 0)
> +            goto error;
> +        break;
> +    case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
> +        if (virDomainGraphicsDefParseXMLSdl(def, node) < 0)
> +            goto error;
> +        break;
> +    case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
> +        if (virDomainGraphicsDefParseXMLRdp(def, node, flags) < 0)
> +            goto error;
> +        break;
> +    case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
> +        if (virDomainGraphicsDefParseXMLDesktop(def, node) < 0)
> +            goto error;
> +        break;
> +    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
> +        if (virDomainGraphicsDefParseXMLSpice(def, node, flags) < 0)
> +            goto error;
> +        break;
>      }
>  




More information about the libvir-list mailing list