WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Additional sanity / compatability checks during guest build.
From: Xen patchbot -3.0-testing <patchbot-3.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 08 Apr 2006 11:12:15 +0000
Delivery-date: Sat, 08 Apr 2006 04:13:01 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 1e3145ad20a683c9c0e26123098164f0c82aa55c
# Parent  32b22f5286beba94318e60704a8058ac3833d502
Additional sanity / compatability checks during guest build. 

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

diff -r 32b22f5286be -r 1e3145ad20a6 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Thu Apr  6 17:34:32 2006
+++ b/tools/libxc/xc_linux_build.c      Fri Apr  7 17:33:36 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 32b22f5286be -r 1e3145ad20a6 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Thu Apr  6 17:34:32 2006
+++ b/tools/libxc/xc_load_elf.c Fri Apr  7 17:33:36 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

<Prev in Thread] Current Thread [Next in Thread>