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

[Xen-devel] [RFC XEN PATCH v4 30/41] tools: reserve extra guest memory for ACPI from device model



The device model may need extra guest memory to store the generated
data when building guest ACPI. For example, QEMU puts the unpatched
ACPI and BIOSLinkerLoader ROMs in guest memory, which can be patched
and loaded by the guest firmware later. Though the default value can
be implied from the type of device model and the domain config, we
still add an xl domain config 'dm_acpi_size' to allow users to specify
the required size when the default value is not enough.

Signed-off-by: Haozhong Zhang <haozhong.zhang@xxxxxxxxx>
---
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 docs/man/xl.cfg.pod.5.in    |  7 +++++++
 tools/libxl/libxl_types.idl |  1 +
 tools/libxl/libxl_x86.c     |  7 ++++++-
 tools/xl/xl_parse.c         | 18 +++++++++++++++++-
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index b7b91d8627..1f9538c445 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1607,6 +1607,13 @@ table. True (1) by default.
 Include the Windows laptop/slate mode switch device in the virtual
 firmware ACPI table. False (0) by default.
 
+=item B<dm_acpi_size=NUMBER>
+
+B<(x86 HVM only)> Reserve the specified bytes of guest memory for ACPI
+built by the device model. The default value is determined according
+to which device model is in use and which ACPI tables are provided by
+that device model.
+
 =item B<apic=BOOLEAN>
 
 B<(x86 only)> Include information regarding APIC (Advanced Programmable 
Interrupt
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index e65bcbbb4f..053b1c0b9a 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -581,6 +581,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("rdm", libxl_rdm_reserve),
                                        ("rdm_mem_boundary_memkb", MemKB),
                                        ("mca_caps",         uint64),
+                                       ("dm_acpi_size",     uint64),
                                        ])),
                  ("pv", Struct(None, [("kernel", string),
                                       ("slack_memkb", MemKB),
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 5f91fe4f92..35ccc7b483 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -364,7 +364,12 @@ int libxl__arch_extra_memory(libxl__gc *gc,
                              const libxl_domain_build_info *info,
                              uint64_t *out)
 {
-    *out = LIBXL_MAXMEM_CONSTANT;
+    uint64_t dm_acpi_size = 0;
+
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM)
+        dm_acpi_size = info->u.hvm.dm_acpi_size;
+
+    *out = LIBXL_MAXMEM_CONSTANT + DIV_ROUNDUP(dm_acpi_size, 1024);
 
     return 0;
 }
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 993b754c0a..0a43a4876e 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -857,7 +857,7 @@ void parse_config_data(const char *config_source,
                        libxl_domain_config *d_config)
 {
     const char *buf;
-    long l, vcpus = 0;
+    long l, vcpus = 0, dm_acpi_size = 0;
     XLU_Config *config;
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
                    *usbctrls, *usbdevs, *p9devs, *vdispls;
@@ -2118,6 +2118,22 @@ skip_usbdev:
 
 #undef parse_extra_args
 
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
+        b_info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
+        /* parse 'dm_acpi_size' */
+        e = xlu_cfg_get_long(config, "dm_acpi_size", &dm_acpi_size, 0);
+        if (e && e != ESRCH) {
+            fprintf(stderr, "ERROR: unable to parse dm_acpi_size.\n");
+            exit(-ERROR_FAIL);
+        }
+        if (!e && dm_acpi_size <= 0) {
+            fprintf(stderr, "ERROR: require positive dm_acpi_size.\n");
+            exit(-ERROR_FAIL);
+        }
+
+        b_info->u.hvm.dm_acpi_size = dm_acpi_size;
+    }
+
     /* If we've already got vfb=[] for PV guest then ignore top level
      * VNC config. */
     if (c_info->type == LIBXL_DOMAIN_TYPE_PV && !d_config->num_vfbs) {
-- 
2.15.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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