libxl: x86: factor out e820_host_sanitize

This function gets the machine E820 map and sanitize it according to PV
guest configuration.

This will be used in later patch. No functional change introduced in
this patch.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Elena Ufimtseva <ufimtseva@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
Wei Liu authored and Ian Campbell committed 2015-03-18 12:04:55 +00:00
1 parent 93493a0817
commit dabacf96aa
1 file changed
+23 -9
+23 -9
View File
@@ -207,6 +207,27 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],
return 0;
}
static int e820_host_sanitize(libxl__gc *gc,
libxl_domain_build_info *b_info,
struct e820entry map[],
uint32_t *nr)
{
int rc;
rc = xc_get_machine_memory_map(CTX->xch, map, *nr);
if (rc < 0) {
errno = rc;
return ERROR_FAIL;
}
*nr = rc;
rc = e820_sanitize(CTX, map, nr, b_info->target_memkb,
(b_info->max_memkb - b_info->target_memkb) +
b_info->u.pv.slack_memkb);
return rc;
}
static int libxl__e820_alloc(libxl__gc *gc, uint32_t domid,
libxl_domain_config *d_config)
{
@@ -223,15 +244,8 @@ static int libxl__e820_alloc(libxl__gc *gc, uint32_t domid,
if (!libxl_defbool_val(b_info->u.pv.e820_host))
return ERROR_INVAL;
rc = xc_get_machine_memory_map(ctx->xch, map, E820MAX);
if (rc < 0) {
errno = rc;
return ERROR_FAIL;
}
nr = rc;
rc = e820_sanitize(ctx, map, &nr, b_info->target_memkb,
(b_info->max_memkb - b_info->target_memkb) +
b_info->u.pv.slack_memkb);
nr = E820MAX;
rc = e820_host_sanitize(gc, b_info, map, &nr);
if (rc)
return ERROR_FAIL;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.