diff mbox

[v3,06/16] libxl: Load guest ACPI table from file

Message ID 1456412174-20162-7-git-send-email-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony PERARD Feb. 25, 2016, 2:56 p.m. UTC
A user can provide a different ACPI tables than the default one by using
the existing "acpi_firmware" xl's config option or the field
u.hvm.acpi_firmware.

libxl will check if the provided table is a DSDT or not.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

---
Change in V3:
- use existing acpi_firmware option to provide an override for the acpi
  tables. Will check if it's a DSDT or an extra tables.
---
 tools/libxl/libxl_dom.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Wei Liu March 1, 2016, 11:51 a.m. UTC | #1
On Thu, Feb 25, 2016 at 02:56:04PM +0000, Anthony PERARD wrote:
> A user can provide a different ACPI tables than the default one by using
> the existing "acpi_firmware" xl's config option or the field
> u.hvm.acpi_firmware.
> 
> libxl will check if the provided table is a DSDT or not.
> 

According to xl.cfg manpage, acpi_firmware= cann't be used to override
DSDT, so you seem to be changing the semantics of existing option.

Wei.
Anthony PERARD March 3, 2016, 5:12 p.m. UTC | #2
On Tue, Mar 01, 2016 at 11:51:43AM +0000, Wei Liu wrote:
> On Thu, Feb 25, 2016 at 02:56:04PM +0000, Anthony PERARD wrote:
> > A user can provide a different ACPI tables than the default one by using
> > the existing "acpi_firmware" xl's config option or the field
> > u.hvm.acpi_firmware.
> > 
> > libxl will check if the provided table is a DSDT or not.
> > 
> 
> According to xl.cfg manpage, acpi_firmware= cann't be used to override
> DSDT, so you seem to be changing the semantics of existing option.

Yes, that was an idea from Ian Campbell <1446634655.6461.48.camel@citrix.com>
I should at least change the manual.

Would it be OK to reuse this options? Or should I add a new option, maybe
acpi_dsdt_override, or some other name?
Wei Liu March 8, 2016, 3:55 p.m. UTC | #3
On Thu, Mar 03, 2016 at 05:12:07PM +0000, Anthony PERARD wrote:
> On Tue, Mar 01, 2016 at 11:51:43AM +0000, Wei Liu wrote:
> > On Thu, Feb 25, 2016 at 02:56:04PM +0000, Anthony PERARD wrote:
> > > A user can provide a different ACPI tables than the default one by using
> > > the existing "acpi_firmware" xl's config option or the field
> > > u.hvm.acpi_firmware.
> > > 
> > > libxl will check if the provided table is a DSDT or not.
> > > 
> > 
> > According to xl.cfg manpage, acpi_firmware= cann't be used to override
> > DSDT, so you seem to be changing the semantics of existing option.
> 
> Yes, that was an idea from Ian Campbell <1446634655.6461.48.camel@citrix.com>
> I should at least change the manual.
> 
> Would it be OK to reuse this options? Or should I add a new option, maybe
> acpi_dsdt_override, or some other name?
> 

If repurposing the old option won't break existing guest then that's
fine, otherwise a new option is required.

Wei.

> -- 
> Anthony PERARD
diff mbox

Patch

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 50abfbc..87853fd 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -905,6 +905,7 @@  static int libxl__domain_firmware(libxl__gc *gc,
     int datalen = 0;
     void *data;
     const char *bios_filename = NULL;
+    const char *full_acpi_tables_filename = NULL;
 
     if (info->u.hvm.firmware)
         firmware = info->u.hvm.firmware;
@@ -964,6 +965,10 @@  static int libxl__domain_firmware(libxl__gc *gc,
                 abort();
             }
         }
+
+        full_acpi_tables_filename =
+            libxl__abs_path(gc, "dsdt_anycpu_qemu_xen.aml",
+                            libxl__xenfirmwaredir_path());
     }
 
     if (bios_filename) {
@@ -1008,6 +1013,27 @@  static int libxl__domain_firmware(libxl__gc *gc,
         }
     }
 
+    /*
+     * Check if the user supplied ACPI tables are the full tables, or if
+     * there are only extra tables. The full tables start with the DSDT
+     * table, and the signature is in the first four bytes.
+     */
+    if (!dom->acpi_module.length
+          || strncmp("DSDT", (char*)dom->acpi_module.data, 4)) {
+        if (full_acpi_tables_filename) {
+            rc = libxl__load_hvm_firmware_module(gc, full_acpi_tables_filename,
+                                                 "ACPI tables",
+                                                 &dom->full_acpi_module);
+            if (rc) goto out;
+        }
+    } else {
+        /* Use user supplied DSDT tables. */
+        dom->full_acpi_module.data = dom->acpi_module.data;
+        dom->full_acpi_module.length = dom->acpi_module.length;
+        dom->acpi_module.length = 0;
+        dom->acpi_module.data = NULL;
+    }
+
     return 0;
 out:
     assert(rc != 0);