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

Re: [libvirt] [PATCH 2/5] nodedev: add <devnode> paths



On Wed, Feb 15, 2017 at 01:04:10AM +0400, marcandre lureau redhat com wrote:
> From: Marc-André Lureau <marcandre lureau redhat com>
> 
> Add new <devnode> top-level <device> element, that list the associated
> /dev files. Distinguish the main /dev name from symlinks with a 'type'
> attribute of value 'dev' or 'symlink'.
> 
> Update a test to check XML schema, and actually add it to the test list
> since it was missing.
> 
> Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
> ---
>  docs/formatnode.html.in                            |  6 +++
>  docs/schemas/nodedev.rng                           | 16 +++++++
>  src/conf/node_device_conf.c                        | 54 +++++++++++++++++++++-
>  src/conf/node_device_conf.h                        | 12 +++++
>  src/node_device/node_device_udev.c                 | 31 +++++++++++++
>  ...ge_serial_3600c0ff000d7a2a5d463ff4902000000.xml |  4 ++
>  tests/nodedevxml2xmltest.c                         |  1 +
>  7 files changed, 123 insertions(+), 1 deletion(-)


> @@ -1722,6 +1736,44 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
>              goto error;
>      }
>  
> +    /* Parse devnodes */
> +    nodes = NULL;
> +    if ((n = virXPathNodeSet("./devnode", ctxt, &nodes)) < 0)
> +        goto error;
> +
> +    if (VIR_ALLOC_N(def->devlinks, n + 1) < 0)
> +        goto error;

Ok, n + 1 because we want to be able to treat it as a string
list with a trailing NULL element. Technically this is still
one element too large, since the first devnode is probably
going to be in dev->devnode intead of dev->devlinks, but
that's harmless enough that we can ignore it.

> +
> +    for (i = 0, m = 0; i < n; i++) {
> +        xmlNodePtr node = nodes[i];
> +        char *tmp = virXMLPropString(node, "type");
> +        virNodeDevDevnodeType type;
> +
> +        if (!tmp) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           "%s", _("missing devnode type"));
> +            goto error;
> +        }
> +
> +        if ((type = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                           _("unknown devnode type '%s'"), tmp);
> +            VIR_FREE(tmp);
> +            goto error;
> +        }
> +
> +        switch (type) {
> +        case VIR_NODE_DEV_DEVNODE_DEV:
> +            def->devnode = (char*)xmlNodeGetContent(node);
> +            break;
> +        case VIR_NODE_DEV_DEVNODE_LINK:
> +            def->devlinks[m++] = (char*)xmlNodeGetContent(node);
> +            break;
> +        case VIR_NODE_DEV_DEVNODE_LAST:
> +            break;
> +        }
> +    }
> +


ACK

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|


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