tools/libxl: Add an unified configuration option for ACPI
authorShannon Zhao <shannon.zhao@linaro.org>
Thu, 29 Sep 2016 01:18:47 +0000 (18:18 -0700)
committerWei Liu <wei.liu2@citrix.com>
Fri, 30 Sep 2016 09:21:55 +0000 (10:21 +0100)
Since the existing configuration option "u.hvm.acpi" is x86 specific and
we want to reuse it on ARM as well, add a unified option "acpi" for
x86 and ARM, and for ARM it's disabled by default.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
docs/man/xl.cfg.pod.5.in
tools/libxl/libxl_arch.h
tools/libxl/libxl_arm.c
tools/libxl/libxl_create.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_types.idl
tools/libxl/libxl_x86.c
tools/libxl/xl_cmdimpl.c

index d8108e3bbb77b28fc6d00c0143d0fc6aa58650a5..21b58bc21e31c8e8b3152993e9d3bae933285107 100644 (file)
@@ -1249,6 +1249,7 @@ the virtual firmware to the guest Operating System. ACPI is required
 by most modern guest Operating Systems. This option is enabled by
 default and usually you should omit it. However it may be necessary to
 disable ACPI for compatibility with some guest Operating Systems.
+This option is true for x86 while it's false for ARM by default.
 
 =item B<acpi_s3=BOOLEAN>
 
index b35f7b6e84fa40a8498373a4804b18198519e38b..fff05548ef0cf89f2febca752c47235d72800b89 100644 (file)
@@ -62,6 +62,10 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
                                         uint32_t domid,
                                         struct xc_dom_image *dom);
 
+_hidden
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info);
+
 #if defined(__i386__) || defined(__x86_64__)
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
index bd3d6116feaabb965689b42a7314bec679d83c1b..8ec5cd562b0092424444afb367e74fb072d783f2 100644 (file)
@@ -985,6 +985,12 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
     return 0;
 }
 
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info)
+{
+    libxl_defbool_setdefault(&b_info->acpi, false);
+}
+
 /*
  * Local variables:
  * mode: C
index 07b2b4b2436c64b9c0e659b6be24da739d9b06a4..d986cd277bd9ee33e75569dfe5b1b0cd5f16642c 100644 (file)
@@ -215,6 +215,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     if (!b_info->event_channels)
         b_info->event_channels = 1023;
 
+    libxl__arch_domain_build_info_acpi_setdefault(b_info);
+
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT)
@@ -454,7 +456,7 @@ int libxl__domain_build(libxl__gc *gc,
         localents = libxl__calloc(gc, 9, sizeof(char *));
         i = 0;
         localents[i++] = "platform/acpi";
-        localents[i++] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
+        localents[i++] = libxl__acpi_defbool_val(info) ? "1" : "0";
         localents[i++] = "platform/acpi_s3";
         localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
         localents[i++] = "platform/acpi_s4";
index e3bf28fc1180e4b9c40c2b0eb8c27e3d853aaa06..ad366a8cd3904a5e021c399a6bddf2f08c993471 100644 (file)
@@ -583,7 +583,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (libxl_defbool_val(b_info->u.hvm.acpi)) {
+        if (libxl__acpi_defbool_val(b_info)) {
             flexarray_append(dm_args, "-acpi");
         }
         if (b_info->max_vcpus > 1) {
@@ -1204,7 +1204,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         if (b_info->u.hvm.soundhw) {
             flexarray_vappend(dm_args, "-soundhw", b_info->u.hvm.soundhw, NULL);
         }
-        if (!libxl_defbool_val(b_info->u.hvm.acpi)) {
+        if (!libxl__acpi_defbool_val(b_info)) {
             flexarray_append(dm_args, "-no-acpi");
         }
         if (b_info->max_vcpus > 1) {
index a8fb23ef81a45824d9e2aeb1e8c6e043321f5aae..f1ba47359059331d2c827b3f6f66acd62f747fcd 100644 (file)
@@ -4292,6 +4292,12 @@ _hidden int libxl__read_sysfs_file_contents(libxl__gc *gc,
 #define LIBXL_QEMU_USER_PREFIX "xen-qemuuser"
 #define LIBXL_QEMU_USER_BASE   LIBXL_QEMU_USER_PREFIX"-domid"
 #define LIBXL_QEMU_USER_SHARED LIBXL_QEMU_USER_PREFIX"-shared"
+
+static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info)
+{
+    return libxl_defbool_val(b_info->acpi) &&
+           libxl_defbool_val(b_info->u.hvm.acpi);
+}
 #endif
 
 /*
index 98bfc3adbcb6ec464528cd6a7a76cd1c5737d1da..a02446f0058ad6137b8129934777befe8ffd4360 100644 (file)
@@ -494,11 +494,15 @@ libxl_domain_build_info = Struct("domain_build_info",[
     # Note that the partial device tree should avoid to use the phandle
     # 65000 which is reserved by the toolstack.
     ("device_tree",      string),
+    ("acpi",             libxl_defbool),
     ("u", KeyedUnion(None, libxl_domain_type, "type",
                 [("hvm", Struct(None, [("firmware",         string),
                                        ("bios",             libxl_bios_type),
                                        ("pae",              libxl_defbool),
                                        ("apic",             libxl_defbool),
+                                       # The following acpi field is deprecated.
+                                       # Please use the unified acpi field above
+                                       # which works for both x86 and ARM.
                                        ("acpi",             libxl_defbool),
                                        ("acpi_s3",          libxl_defbool),
                                        ("acpi_s4",          libxl_defbool),
index 0190baa8a79b6652e119b22f31a9ae44e62aefac..84493df8ef254598eaffe917a4fa50786d590269 100644 (file)
@@ -573,6 +573,12 @@ out:
     return rc;
 }
 
+void libxl__arch_domain_build_info_acpi_setdefault(
+                                        libxl_domain_build_info *b_info)
+{
+    libxl_defbool_setdefault(&b_info->acpi, true);
+}
+
 /*
  * Local variables:
  * mode: C
index cb43c00177b9f6f06e5ab242c66f770b0467d184..1e93b1b03c46d34b3a9a639494e90ac6e4f4a2c8 100644 (file)
@@ -1550,6 +1550,7 @@ static void parse_config_data(const char *config_source,
     b_info->cmdline = parse_cmdline(config);
 
     xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0);
+    xlu_cfg_get_defbool(config, "acpi", &b_info->acpi, 0);
 
     switch(b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
@@ -1579,7 +1580,6 @@ static void parse_config_data(const char *config_source,
 
         xlu_cfg_get_defbool(config, "pae", &b_info->u.hvm.pae, 0);
         xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
-        xlu_cfg_get_defbool(config, "acpi", &b_info->u.hvm.acpi, 0);
         xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0);
         xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
         xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);