As {alloc,free}_domain_struct() are used only within domain.c,
they can be declared static and their declarations removed
from xen/domain.h.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
Changes in v2:
- New patch.
---
xen/common/domain.c | 6 ++++--
xen/include/xen/domain.h | 4 ----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 92fc0684fc..7509dafd6f 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -690,6 +690,8 @@ static int domain_teardown(struct domain *d)
return 0;
}
+static void free_domain_struct(struct domain *d);
+
/*
* Destroy a domain once all references to it have been dropped. Used either
* from the RCU path, or from the domain_create() error path before the domain
@@ -819,7 +821,7 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
return arch_sanitise_domain_config(config);
}
-struct domain *alloc_domain_struct(void)
+static struct domain *alloc_domain_struct(void)
{
#ifndef arch_domain_struct_memflags
# define arch_domain_struct_memflags() 0
@@ -835,7 +837,7 @@ struct domain *alloc_domain_struct(void)
return d;
}
-void free_domain_struct(struct domain *d)
+static void free_domain_struct(struct domain *d)
{
free_xenheap_page(d);
}
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index 644f5ac3f2..273717c31b 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -66,10 +66,6 @@ void domid_free(domid_t domid);
* Arch-specifics.
*/
-/* Allocate/free a domain structure. */
-struct domain *alloc_domain_struct(void);
-void free_domain_struct(struct domain *d);
-
/* Allocate/free a PIRQ structure. */
#ifndef alloc_pirq_struct
struct pirq *alloc_pirq_struct(struct domain *d);
--
2.52.0
On 18/12/2025 5:28 pm, Oleksii Kurochko wrote:
> As {alloc,free}_domain_struct() are used only within domain.c,
> they can be declared static and their declarations removed
> from xen/domain.h.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> Changes in v2:
> - New patch.
> ---
> xen/common/domain.c | 6 ++++--
> xen/include/xen/domain.h | 4 ----
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 92fc0684fc..7509dafd6f 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -690,6 +690,8 @@ static int domain_teardown(struct domain *d)
> return 0;
> }
>
> +static void free_domain_struct(struct domain *d);
> +
Another option would be to move them both up here, and avoid the forward
declaration. It's a bigger patch, but results in domain.c being
slightly less complex.
~Andrew
On 12/18/25 7:21 PM, Andrew Cooper wrote:
> On 18/12/2025 5:28 pm, Oleksii Kurochko wrote:
>> As {alloc,free}_domain_struct() are used only within domain.c,
>> they can be declared static and their declarations removed
>> from xen/domain.h.
>>
>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Thanks.
>> ---
>> Changes in v2:
>> - New patch.
>> ---
>> xen/common/domain.c | 6 ++++--
>> xen/include/xen/domain.h | 4 ----
>> 2 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/common/domain.c b/xen/common/domain.c
>> index 92fc0684fc..7509dafd6f 100644
>> --- a/xen/common/domain.c
>> +++ b/xen/common/domain.c
>> @@ -690,6 +690,8 @@ static int domain_teardown(struct domain *d)
>> return 0;
>> }
>>
>> +static void free_domain_struct(struct domain *d);
>> +
> Another option would be to move them both up here, and avoid the forward
> declaration. It's a bigger patch, but results in domain.c being
> slightly less complex.
Then I will move both|free_domain_struct()| and|alloc_domain_struct()| (to keep them
together) to the place where the forward declaration of|free_domain_struct()| is
introduced in this patch.
Does that work for you?
~ Oleksii
© 2016 - 2026 Red Hat, Inc.