libxl: switch device model selection over to libxl_defbool
authorIan Campbell <ian.campbell@citrix.com>
Thu, 1 Mar 2012 12:26:15 +0000 (12:26 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 1 Mar 2012 12:26:15 +0000 (12:26 +0000)
This allows it to be set via the _init/_setdefault methods.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[since last v -- ERROR_INVAL on stubdomains + !traditional qemu]

tools/libxl/libxl.c
tools/libxl/libxl_create.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_types.idl
tools/libxl/xl_cmdimpl.c

index 92b07a9b889770df1b72f357548867cb0cd3c1b4..d66191a57db3ff573355e010d2abec14949fb6a5 100644 (file)
@@ -2714,7 +2714,7 @@ int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info,
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         *need_memkb += b_info->shadow_memkb + LIBXL_HVM_EXTRA_MEMORY;
-        if (b_info->device_model_stubdomain)
+        if (libxl_defbool_val(b_info->device_model_stubdomain))
             *need_memkb += 32 * 1024;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
index 172ff976ef9aecd7202a44383c4231a472fedb8f..9f67e9539bfc743670d95c8e563fb33e154ac31e 100644 (file)
@@ -80,9 +80,6 @@ void libxl_domain_build_info_init(libxl_domain_build_info *b_info,
     b_info->shadow_memkb = LIBXL_MEMKB_DEFAULT;
     b_info->video_memkb =  LIBXL_MEMKB_DEFAULT;
 
-    b_info->device_model_stubdomain = false;
-    b_info->device_model = NULL;
-
     switch (b_info->type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         b_info->u.hvm.timer_mode = LIBXL_TIMER_MODE_DEFAULT;
@@ -122,6 +119,17 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
     default:abort();
     }
 
+    libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
+        b_info->device_model_version !=
+            LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+        libxl_defbool_val(b_info->device_model_stubdomain)) {
+        LIBXL__LOG(CTX, XTL_ERROR,
+            "device model stubdomains require \"qemu-xen-traditional\"");
+        return ERROR_INVAL;
+    }
+
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
     if (!b_info->cur_vcpus)
index a4f4d440ec52f0ef2553f91da61c21774edc19ea..3715b45d110cf16da05d1b6acdbc1f1178ef17ac 100644 (file)
@@ -39,7 +39,7 @@ const char *libxl__domain_device_model(libxl__gc *gc,
     libxl_ctx *ctx = libxl__gc_owner(gc);
     const char *dm;
 
-    if (info->device_model_stubdomain)
+    if (libxl_defbool_val(info->device_model_stubdomain))
         return NULL;
 
     if (info->device_model) {
@@ -899,7 +899,7 @@ int libxl__create_device_model(libxl__gc *gc,
     char **pass_stuff;
     const char *dm;
 
-    if (b_info->device_model_stubdomain) {
+    if (libxl_defbool_val(b_info->device_model_stubdomain)) {
         rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r);
         goto out;
     }
index 49df3004579eae85a62950be2907ef851407680b..d93f40143cea0eedfa913e6c67eeb870ee9727ab 100644 (file)
@@ -240,8 +240,8 @@ libxl_domain_build_info = Struct("domain_build_info",[
     ("type",            libxl_domain_type),
     
     ("device_model_version", libxl_device_model_version),
-    ("device_model_stubdomain", bool),
-    # you set device_model you must set device_model_version too
+    ("device_model_stubdomain", libxl_defbool),
+    # if you set device_model you must set device_model_version too
     ("device_model",     string),
     ("device_model_ssidref", uint32),
 
index beb08429018a022c61358a44375c14f2436801f9..bd92f54354300ecd116b5d6679abb4395bb54435 100644 (file)
@@ -1125,8 +1125,8 @@ skip_vfb:
         }
     } else if (b_info->device_model)
         fprintf(stderr, "WARNING: device model override given without specific DM version\n");
-    if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0))
-        b_info->device_model_stubdomain = l;
+    xlu_cfg_get_defbool (config, "device_model_stubdomain_override",
+                         &b_info->device_model_stubdomain, 0);
 
     if (!xlu_cfg_get_string (config, "device_model_stubdomain_seclabel",
                              &buf, 0)) {