]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: check nesthvm and altp2m in libxl
authorWei Liu <wei.liu2@citrix.com>
Mon, 27 Jul 2015 14:01:32 +0000 (15:01 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 28 Jul 2015 10:04:12 +0000 (11:04 +0100)
In ea214001 ("x86/altp2m: add altp2mhvm HVM domain parameter"), a
check was added to ensure nestedhvm and altp2m cannot be enabled at
the same time. That check was added in xl, but in fact it should be in
libxl because it should be the entity that decides whether
the provided configuration is valid.

This patch moves the check to libxl. The code snippet is moved after
calling libxl__domain_build_info_setdefault so that we can:
1. remove libxl_defbool_is_default in `if()';
2. detect mistake in libxl__domain_build_info_setdefault.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_create.c
tools/libxl/xl_cmdimpl.c

index 855b42c831137ed6f3b9e68b870cfc272dfe96af..0294844ac430a1dbe15839543cb047f58f8129c7 100644 (file)
@@ -883,6 +883,13 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
+        (libxl_defbool_val(d_config->b_info.u.hvm.nested_hvm) &&
+         libxl_defbool_val(d_config->b_info.u.hvm.altp2m))) {
+        LOG(ERROR, "nestedhvm and altp2mhvm cannot be used together");
+        goto error_out;
+    }
+
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]);
         if (ret) {
index d0bf0cb92426d60b7af3fdf905a36b566f812cf9..9755d552601d7b95638fd5a1f5f1dbb9c21f8012 100644 (file)
@@ -1568,14 +1568,6 @@ static void parse_config_data(const char *config_source,
 
         xlu_cfg_get_defbool(config, "altp2mhvm", &b_info->u.hvm.altp2m, 0);
 
-        if (!libxl_defbool_is_default(b_info->u.hvm.nested_hvm) &&
-            libxl_defbool_val(b_info->u.hvm.nested_hvm) &&
-            !libxl_defbool_is_default(b_info->u.hvm.altp2m) &&
-            libxl_defbool_val(b_info->u.hvm.altp2m)) {
-            fprintf(stderr, "ERROR: nestedhvm and altp2mhvm cannot be used together\n");
-            exit(1);
-        }
-
         xlu_cfg_replace_string(config, "smbios_firmware",
                                &b_info->u.hvm.smbios_firmware, 0);
         xlu_cfg_replace_string(config, "acpi_firmware",