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

Re: [PATCH v1 17/18] builder: introduce domain builder hypfs tree


  • To: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 27 Jul 2022 16:30:43 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=axuX18RS7W5qUjIfqjMh+CQO5ugvudP9Jor8Vpxq43E=; b=f03jcYRo2gcmtJjxD44vJTOEq3ziFdJkgeZajdS7mW6xmqn6KqHv3QRzMtb6JCV2aHrXaubJLQbf9xbM0jpZrtV8FvzdDZa7Xi8f2TL5FoSa3xmx+KPQVz9vXImFfHgOZWjgayHubfvXe6vPSjmLxh1XvPtI+Gv6c8FniXP5Pp4QIxd7ZjgMuLgSz6SrmD9FI1JPtI9pqYdRSwBT/imaETUoI+hWU/GDaBdc1tT9QQfpYMr1Oz3m0gJkvs1iQ/t5fh7ablkBbuRn0qIA/+jWZrQqR12swUE8tzIaifmMt6owUXqfLYbDH3HmWl4rDkMDatY6ZpjV/OGFLhs9A1aMNw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFAdwMIRl79b06CYB0FVzB9HZxVgtBnmt1YCmuoAAzciSty9LlgM/+5AQK0rtHbSO91X6GiuRosc8rVpoUfN+I/tLHx0Re+iyd6bv2cB7KGy/f73iJCGbpPKtcIFYWXRa5GsAIS2wbFoKKy2vy84lLlluV7HF3G1DPvbZXLkn5Zgs5DDLjAR/q+Ua6dq+01Jt4TtBzOaYeZmmqKKE+aG7ntVO9taf6jomDKH2potFfIs/RTX1r6CM5q79Z419zSU1k/Yp7RRp9x2TtrDWIzIwUa+6K/0/4HHua8cbKsiB4ud8z5fBiKeaid+0za+x2YgSWKPj2sZV4SC8zlMMFpLJA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: scott.davis@xxxxxxxxxx, christopher.clark@xxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 27 Jul 2022 14:31:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.07.2022 23:04, Daniel P. Smith wrote:
> --- a/xen/common/domain-builder/core.c
> +++ b/xen/common/domain-builder/core.c
> @@ -134,6 +134,9 @@ uint32_t __init builder_create_domains(struct boot_info 
> *info)
>          /* Free temporary buffers. */
>          discard_initial_images();
>  
> +    if ( IS_ENABLED(CONFIG_BUILDER_HYPFS) )
> +        builder_hypfs(info);

No need for the if() here when you provide a stub in the header file.
Just that of course the stub vs prototype there needs to depend on
CONFIG_BUILDER_HYPFS, not CONFIG_HYPFS.

> +static int __init alloc_hypfs(struct boot_info *info)
> +{
> +    if ( !(builder_dir = (struct hypfs_entry_dir *)xmalloc_bytes(
> +                        sizeof(struct hypfs_entry_dir))) )

Why not xmalloc() (or xzalloc()), which specifically exists to avoid
open-coded casts like the one here?

> +    {
> +        printk(XENLOG_WARNING "%s: unable to allocate hypfs dir\n", 
> __func__);
> +        return -ENOMEM;
> +    }
> +
> +    builder_dir->e.type = XEN_HYPFS_TYPE_DIR;
> +    builder_dir->e.encoding = XEN_HYPFS_ENC_PLAIN;
> +    builder_dir->e.name = "builder";
> +    builder_dir->e.size = 0;
> +    builder_dir->e.max_size = 0;
> +    INIT_LIST_HEAD(&builder_dir->e.list);
> +    builder_dir->e.funcs = &hypfs_dir_funcs;
> +    INIT_LIST_HEAD(&builder_dir->dirlist);
> +
> +    if ( !(entries = (struct domain_node *)xmalloc_bytes(
> +                        sizeof(struct domain_node) * 
> info->builder->nr_doms)) )

xmalloc_array()?

> +    {
> +        printk(XENLOG_WARNING "%s: unable to allocate hypfs nodes\n", 
> __func__);
> +        return -ENOMEM;
> +    }
> +
> +    return 0;
> +}
> +
> +void __init builder_hypfs(struct boot_info *info)
> +{
> +    int i;
> +
> +    printk("Domain Builder: creating hypfs nodes\n");

If at all, then dprintk().

> +    if ( alloc_hypfs(info) != 0 )
> +        return;
> +
> +    for ( i = 0; i < info->builder->nr_doms; i++ )
> +    {
> +        struct domain_node *e = &entries[i];
> +        struct boot_domain *bd = &info->builder->domains[i];
> +        uint8_t *uuid = bd->uuid;
> +
> +        snprintf(e->dir_name, sizeof(e->dir_name), "%d", bd->domid);
> +
> +        snprintf(e->uuid, sizeof(e->uuid), "%08x-%04x-%04x-%04x-%04x%08x",
> +                 *(uint32_t *)uuid, *(uint16_t *)(uuid+4),
> +                 *(uint16_t *)(uuid+6), *(uint16_t *)(uuid+8),
> +                 *(uint16_t *)(uuid+10), *(uint32_t *)(uuid+12));

Perhaps better introduce a properly typed structure? Endian-ness-wise
I'm also unsure about the last 12 nibbles: Isn't this an array of bytes
really? Actually the second-to-last 16-bit item is an array of two
bytes as well, if Linux'es %pU vsprintf() formatting is to be trusted.

> +        e->functions = bd->functions;
> +        e->constructed = bd->constructed;
> +
> +        e->ncpus = bd->ncpus;
> +        e->mem_size = (bd->meminfo.mem_size.nr_pages * PAGE_SIZE)/1024;
> +        e->mem_max = (bd->meminfo.mem_max.nr_pages * PAGE_SIZE)/1024;

Nit: Blanks around / please.

> +        e->xs.evtchn = bd->store.evtchn;
> +        e->xs.mfn = bd->store.mfn;
> +
> +        e->con_dev.evtchn = bd->console.evtchn;
> +        e->con_dev.mfn = bd->console.mfn;
> +
> +        /* Initialize and construct builder hypfs tree */
> +        INIT_HYPFS_DIR(e->dir, e->dir_name);
> +        INIT_HYPFS_DIR(e->xs.dir, "xenstore");
> +        INIT_HYPFS_DIR(e->dev_dir, "devices");
> +        INIT_HYPFS_DIR(e->con_dev.dir, "console");
> +
> +        INIT_HYPFS_STRING(e->uuid_leaf, "uuid");
> +        hypfs_string_set_reference(&e->uuid_leaf, e->uuid);
> +        INIT_HYPFS_UINT(e->func_leaf, "functions", e->functions);
> +        INIT_HYPFS_UINT(e->ncpus_leaf, "ncpus", e->ncpus);
> +        INIT_HYPFS_UINT(e->mem_sz_leaf, "mem_size", e->mem_size);
> +        INIT_HYPFS_UINT(e->mem_mx_leaf, "mem_max", e->mem_max);

May I suggest to prefer - over _ in node names?

> --- a/xen/include/xen/domain_builder.h
> +++ b/xen/include/xen/domain_builder.h
> @@ -72,4 +72,17 @@ int alloc_system_evtchn(
>      const struct boot_info *info, struct boot_domain *bd);
>  void arch_create_dom(const struct boot_info *bi, struct boot_domain *bd);
>  
> +#ifdef CONFIG_HYPFS
> +
> +void builder_hypfs(struct boot_info *info);
> +
> +#else
> +
> +static inline void builder_hypfs(struct boot_info *info)
> +{
> +    return;
> +}
> +
> +#endif

This would better go in a private header in xen/common/domain-builder/.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.