Re: [libvirt PATCHv1 3/8] conf: move idmap parsing earlier

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

 



On 9/11/23 15:51, Ján Tomko wrote:
> Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
> ---
>  src/conf/domain_conf.c | 98 +++++++++++++++++++++---------------------
>  1 file changed, 49 insertions(+), 49 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 2c8727de54..dd67e7f21b 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -8581,6 +8581,55 @@ virDomainNetGenerateMAC(virDomainXMLOption *xmlopt,
>  }
>  
>  
> +static int virDomainIdMapEntrySort(const void *a, const void *b)
> +{
> +    const virDomainIdMapEntry *entrya = a;
> +    const virDomainIdMapEntry *entryb = b;
> +
> +    if (entrya->start > entryb->start)
> +        return 1;
> +    else if (entrya->start < entryb->start)
> +        return -1;
> +    else
> +        return 0;
> +}
> +

Please put an extra empty line here.

> +/* Parse the XML definition for user namespace id map.
> + *
> + * idmap has the form of
> + *
> + *   <uid start='0' target='1000' count='10'/>
> + *   <gid start='0' target='1000' count='10'/>
> + */
> +static virDomainIdMapEntry *
> +virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
> +                          xmlNodePtr *node,
> +                          size_t num)
> +{
> +    size_t i;
> +    virDomainIdMapEntry *idmap = NULL;
> +    VIR_XPATH_NODE_AUTORESTORE(ctxt)
> +
> +    idmap = g_new0(virDomainIdMapEntry, num);
> +
> +    for (i = 0; i < num; i++) {
> +        ctxt->node = node[i];
> +        if (virXPathUInt("string(./@start)", ctxt, &idmap[i].start) < 0 ||
> +            virXPathUInt("string(./@target)", ctxt, &idmap[i].target) < 0 ||
> +            virXPathUInt("string(./@count)", ctxt, &idmap[i].count) < 0) {
> +            virReportError(VIR_ERR_XML_ERROR, "%s",
> +                           _("invalid idmap start/target/count settings"));
> +            VIR_FREE(idmap);
> +            return NULL;
> +        }
> +    }
> +
> +    qsort(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort);
> +
> +    return idmap;
> +}
> +
> +

Michal




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

  Powered by Linux