Skip to content

Commit

Permalink
xen-dom-mgmt: Add weak functions for user configurations
Browse files Browse the repository at this point in the history
Provide weak functions for user configurations in the xen-dom-mgmt
allowing apps to extend the list of configurations for a domain.

Signed-off-by: Mykyta Poturai <[email protected]>
  • Loading branch information
Deedone committed May 7, 2024
1 parent 88e6553 commit 431066c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions xen-dom-mgmt/include/xen_dom_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ int domain_post_create(const struct xen_domain_cfg *domcfg, uint32_t domid);
*/
struct xen_domain_cfg *domain_find_config(char *name);

/**
* This function returns the count of user configurations for a domain.
*
* The function is defined as weak, so it can be overridden by the user.
* @return The count of user configurations.
*/
int domain_get_user_cfg_count(void);

/**
* This function returns the user configuration for a domain specified by the given index.
*
* The function is defined as weak, so it can be overridden by the user.
* @param id The ID of the domain.
* @return The user configuration for the domain, or NULL if not found.
*/
struct xen_domain_cfg *domain_get_user_cfg(int index);

#ifdef CONFIG_XEN_DOMCFG_SECTION
#define DECL_CONFIG static __section(".domain_configs") __used
extern struct xen_domain_cfg _domain_configs_start[];
Expand Down
19 changes: 19 additions & 0 deletions xen-dom-mgmt/src/xen-dom-mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ struct xen_domain *domid_to_domain(uint32_t domid)
struct xen_domain_cfg *domain_find_config(char *name)
{
__maybe_unused struct xen_domain_cfg *cfg = NULL;
int i;

for (i = 0; i < domain_get_user_cfg_count(); i++) {
cfg = domain_get_user_cfg(i);
if (strncmp(cfg->name, name, CONTAINER_NAME_SIZE) == 0) {
return cfg;
}
}

#ifdef CONFIG_XEN_DOMCFG_SECTION
for (cfg = _domain_configs_start; cfg < _domain_configs_end; cfg++) {
Expand All @@ -632,6 +640,17 @@ struct xen_domain_cfg *domain_find_config(char *name)
return NULL;
}

__weak int domain_get_user_cfg_count(void)
{
return 0;
}

__weak struct xen_domain_cfg *domain_get_user_cfg(int index)
{
ARG_UNUSED(index);
return NULL;
}

int domain_create(struct xen_domain_cfg *domcfg, uint32_t domid)
{
int rc = 0;
Expand Down

0 comments on commit 431066c

Please sign in to comment.