libxl: Select BIOS using libxl_domain_build_info_setdefaults
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)
Remove libxl__domain_bios -- it is no longer necessary.

Also we appear to have been setting the xenstore key even for device models for
PV guests -- stop doing that.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_create.c
tools/libxl/libxl_dm.c

index ca48e329584b63d2c589d6c1a91a59a5094d6ee1..90ede958320b2f29bfcf9c0483fe0b39cf024361 100644 (file)
@@ -109,6 +109,26 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         b_info->device_model_version =
             LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
 
+    if (!b_info->u.hvm.bios)
+        switch (b_info->device_model_version) {
+        case 1: b_info->u.hvm.bios = LIBXL_BIOS_TYPE_ROMBIOS; break;
+        case 2: b_info->u.hvm.bios = LIBXL_BIOS_TYPE_SEABIOS; break;
+        default:return ERROR_INVAL;
+    }
+
+    /* Enforce BIOS<->Device Model version relationship */
+    switch (b_info->device_model_version) {
+    case 1:
+        if (b_info->u.hvm.bios != LIBXL_BIOS_TYPE_ROMBIOS)
+            return ERROR_INVAL;
+        break;
+    case 2:
+        if (b_info->u.hvm.bios == LIBXL_BIOS_TYPE_ROMBIOS)
+            return ERROR_INVAL;
+        break;
+    default:abort();
+    }
+
     if (!b_info->max_vcpus)
         b_info->max_vcpus = 1;
     if (!b_info->cur_vcpus)
index db71f38d41f55c3315b46662710fe53fa886d825..a4f4d440ec52f0ef2553f91da61c21774edc19ea 100644 (file)
@@ -63,18 +63,6 @@ const char *libxl__domain_device_model(libxl__gc *gc,
     return dm;
 }
 
-static const char *libxl__domain_bios(libxl__gc *gc,
-                                const libxl_domain_build_info *info)
-{
-    if (info->u.hvm.bios)
-       return libxl_bios_type_to_string(info->u.hvm.bios);
-    switch (info->device_model_version) {
-    case 1: return "rombios";
-    case 2: return "seabios";
-    default:return NULL;
-    }
-}
-
 const libxl_vnc_info *libxl__dm_vnc(const libxl_domain_config *guest_config)
 {
     const libxl_vnc_info *vnc = NULL;
@@ -933,10 +921,13 @@ int libxl__create_device_model(libxl__gc *gc,
         goto out;
     }
 
-    path = xs_get_domain_path(ctx->xsh, domid);
-    libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/hvmloader/bios", path),
-                    "%s", libxl__domain_bios(gc, b_info));
-    free(path);
+    if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+        path = xs_get_domain_path(ctx->xsh, domid);
+        libxl__xs_write(gc, XBT_NULL,
+                        libxl__sprintf(gc, "%s/hvmloader/bios", path),
+                        "%s", libxl_bios_type_to_string(b_info->u.hvm.bios));
+        free(path);
+    }
 
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid);
     xs_mkdir(ctx->xsh, XBT_NULL, path);