[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Additional sanity / compatability checks during guest build.



# HG changeset patch
# User smh22@xxxxxxxxxxxxxxxxxxxx
# Node ID 86db4688d514e2ab6e5b3e927a0c892ad9d597bf
# Parent  3b0d07af46cb0c456912b287a0365172746ae9e0
Additional sanity / compatability checks during guest build. 

Signed-off-by: Steven Hand <steven@xxxxxxxxxxxxx>

diff -r 3b0d07af46cb -r 86db4688d514 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Fri Apr  7 13:27:46 2006
+++ b/tools/libxc/xc_linux_build.c      Fri Apr  7 14:58:00 2006
@@ -110,10 +110,10 @@
 
         if ( i == XENFEAT_NR_SUBMAPS*32 )
         {
-            ERROR("Unknown feature \"%.*s\".\n", (int)(p-feats), feats);
+            ERROR("Unknown feature \"%.*s\".", (int)(p-feats), feats);
             if ( req )
             {
-                ERROR("Kernel requires an unknown hypervisor feature.\n");
+                ERROR("Kernel requires an unknown hypervisor feature.");
                 return -EINVAL;
             }
         }
@@ -579,6 +579,31 @@
     return -1;
 }
 #else /* x86 */
+
+/* Check if the platform supports the guest kernel format */
+static int compat_check(int xc_handle, struct domain_setup_info *dsi)
+{
+    xen_capabilities_info_t xen_caps = "";
+
+    if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0) {
+        ERROR("Cannot determine host capabilities.");
+        return 0;
+    }
+
+    if (strstr(xen_caps, "xen-3.0-x86_32p")) {
+        if (!dsi->pae_kernel) {
+            ERROR("Non PAE-kernel on PAE host.");
+            return 0;
+        }
+    } else if (dsi->pae_kernel) {
+        ERROR("PAE-kernel on non-PAE host.");
+        return 0;
+    }
+
+    return 1;
+}
+
+
 static int setup_guest(int xc_handle,
                        uint32_t dom,
                        const char *image, unsigned long image_size,
@@ -635,9 +660,12 @@
 
     if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
     {
-        PERROR("Guest OS must load to a page boundary.\n");
-        goto error_out;
-    }
+        PERROR("Guest OS must load to a page boundary.");
+        goto error_out;
+    }
+
+    if (!compat_check(xc_handle, &dsi))
+        goto error_out;
 
     /* Parse and validate kernel features. */
     p = strstr(dsi.xen_guest_string, "FEATURES=");
@@ -647,7 +675,7 @@
                              supported_features,
                              required_features) )
         {
-            ERROR("Failed to parse guest kernel features.\n");
+            ERROR("Failed to parse guest kernel features.");
             goto error_out;
         }
 
@@ -659,7 +687,7 @@
     {
         if ( (supported_features[i]&required_features[i]) != 
required_features[i] )
         {
-            ERROR("Guest kernel does not support a required feature.\n");
+            ERROR("Guest kernel does not support a required feature.");
             goto error_out;
         }
     }
diff -r 3b0d07af46cb -r 86db4688d514 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Fri Apr  7 13:27:46 2006
+++ b/tools/libxc/xc_load_elf.c Fri Apr  7 14:58:00 2006
@@ -66,6 +66,21 @@
     if ( !IS_ELF(*ehdr) )
     {
         ERROR("Kernel image does not have an ELF header.");
+        return -EINVAL;
+    }
+
+    if (
+#if defined(__i386__)
+        (ehdr->e_ident[EI_CLASS] != ELFCLASS32) ||
+        (ehdr->e_machine != EM_386) ||
+#elif defined(__x86_64__)
+        (ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
+        (ehdr->e_machine != EM_X86_64) ||
+#endif
+        (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) ||
+        (ehdr->e_type != ET_EXEC) )
+    {
+        ERROR("Kernel not a Xen-compatible Elf image.");
         return -EINVAL;
     }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.