#include "libxl_osdeps.h"
#include "libxl_internal.h"
+#include "libxl_arch.h"
#define PAGE_TO_MEMKB(pages) ((pages) * 4)
#define BACKEND_STRING_SIZE 5
{
GC_INIT(ctx);
char *mem, *endptr;
- uint64_t memorykb;
+ uint64_t memorykb, size;
char *dompath = libxl__xs_get_dompath(gc, domid);
int rc = 1;
libxl__domain_userdata_lock *lock = NULL;
+ libxl_domain_config d_config;
CTX_LOCK;
"memory_static_max must be greater than or or equal to memory_dynamic_max");
goto out;
}
- rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + LIBXL_MAXMEM_CONSTANT);
+
+ rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+ if (rc < 0) {
+ LOGE(ERROR, "unable to retrieve domain configuration");
+ goto out;
+ }
+
+ rc = libxl__arch_extra_memory(gc, &d_config.b_info, &size);
+ if (rc < 0) {
+ LOGE(ERROR, "Couldn't get arch extra constant memory size");
+ goto out;
+ }
+
+ rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + size);
if (rc != 0) {
LOGE(ERROR,
"xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed ""rc=%d\n",
- domid, max_memkb + LIBXL_MAXMEM_CONSTANT, rc);
+ domid, max_memkb + size, rc);
goto out;
}
{
GC_INIT(ctx);
int rc, r, lrc, abort_transaction = 0;
- uint64_t memorykb;
+ uint64_t memorykb, size;
uint64_t videoram = 0;
uint64_t current_target_memkb = 0, new_target_memkb = 0;
uint64_t current_max_memkb = 0;
char *uuid;
xs_transaction_t t;
libxl__domain_userdata_lock *lock;
+ libxl_domain_config d_config;
CTX_LOCK;
goto out_no_transaction;
}
+ rc = libxl_retrieve_domain_configuration(ctx, domid, &d_config);
+ if (rc < 0) {
+ LOGE(ERROR, "unable to retrieve domain configuration");
+ goto out_no_transaction;
+ }
+
+ rc = libxl__arch_extra_memory(gc, &d_config.b_info, &size);
+ if (rc < 0) {
+ LOGE(ERROR, "Couldn't get arch extra constant memory size");
+ goto out_no_transaction;
+ }
+
retry_transaction:
t = xs_transaction_start(ctx->xsh);
if (enforce) {
memorykb = new_target_memkb + videoram;
- r = xc_domain_setmaxmem(ctx->xch, domid, memorykb +
- LIBXL_MAXMEM_CONSTANT);
+ r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size);
if (r != 0) {
LOGE(ERROR,
"xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed ""rc=%d\n",
domid,
- memorykb + LIBXL_MAXMEM_CONSTANT,
+ memorykb + size,
r);
abort_transaction = 1;
rc = ERROR_FAIL;
}
r = xc_domain_set_pod_target(ctx->xch, domid,
- (new_target_memkb + LIBXL_MAXMEM_CONSTANT) / 4, NULL, NULL, NULL);
+ (new_target_memkb + size) / 4, NULL, NULL, NULL);
if (r != 0) {
LOGE(ERROR,
"xc_domain_set_pod_target domid=%d, memkb=%"PRIu64" failed rc=%d\n",
domid,
- new_target_memkb / 4,
+ (new_target_memkb + size) / 4,
r);
abort_transaction = 1;
rc = ERROR_FAIL;
void libxl__arch_domain_build_info_acpi_setdefault(
libxl_domain_build_info *b_info);
+_hidden
+int libxl__arch_extra_memory(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out);
+
#if defined(__i386__) || defined(__x86_64__)
#define LAPIC_BASE_ADDRESS 0xfee00000
return 0;
}
+int libxl__arch_extra_memory(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out)
+{
+ int rc = 0;
+ uint64_t size = 0;
+
+ if (libxl_defbool_val(info->acpi)) {
+ rc = libxl__get_acpi_size(gc, info, &size);
+ if (rc < 0) {
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ }
+
+ *out = LIBXL_MAXMEM_CONSTANT + DIV_ROUNDUP(size, 1024);
+out:
+ return rc;
+}
+
static struct arch_info {
const char *guest_type;
const char *timer_compat;
int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
struct xc_dom_image *dom);
+_hidden
+int libxl__get_acpi_size(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out);
+
static inline uint64_t libxl__compute_mpdir(unsigned int cpuid)
{
/*
return rc;
}
+int libxl__get_acpi_size(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out)
+{
+ uint64_t size;
+ int rc = 0;
+
+
+ rc = libxl__estimate_madt_size(gc, info, &size);
+ if (rc < 0)
+ goto out;
+
+ *out = ROUNDUP(size, 3) +
+ ROUNDUP(sizeof(struct acpi_table_rsdp), 3) +
+ ROUNDUP(sizeof(struct acpi_table_xsdt), 3) +
+ ROUNDUP(sizeof(struct acpi_table_gtdt), 3) +
+ ROUNDUP(sizeof(struct acpi_table_fadt), 3) +
+ ROUNDUP(sizeof(dsdt_anycpu_arm_len), 3);
+
+out:
+ return rc;
+}
+
static int libxl__allocate_acpi_tables(libxl__gc *gc,
libxl_domain_build_info *info,
struct xc_dom_image *dom,
return ERROR_FAIL;
}
+int libxl__get_acpi_size(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out)
+{
+ return ERROR_FAIL;
+}
+
/*
* Local variables:
* mode: C
libxl_ctx *ctx = libxl__gc_owner(gc);
char *xs_domid, *con_domid;
int rc;
+ uint64_t size;
if (xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus) != 0) {
LOG(ERROR, "Couldn't set max vcpu count");
}
}
- if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
- LIBXL_MAXMEM_CONSTANT) < 0) {
+
+ rc = libxl__arch_extra_memory(gc, info, &size);
+ if (rc < 0) {
+ LOGE(ERROR, "Couldn't get arch extra constant memory size");
+ return ERROR_FAIL;
+ }
+
+ if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + size) < 0) {
LOGE(ERROR, "Couldn't set max memory");
return ERROR_FAIL;
}
#define ROUNDUP(_val, _order) \
(((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1))
+#define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d))
+
#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
return ret;
}
+int libxl__arch_extra_memory(libxl__gc *gc,
+ const libxl_domain_build_info *info,
+ uint64_t *out)
+{
+ *out = LIBXL_MAXMEM_CONSTANT;
+
+ return 0;
+}
+
int libxl__arch_domain_init_hw_description(libxl__gc *gc,
libxl_domain_build_info *info,
libxl__domain_build_state *state,