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

Re: Bug#425648: grub: Hang occurring slightly later for me



reassign 425648 grub-installer
thanks

Hi folks;  GRUB 2 doesn't have this problem, and nobody seems interested in
debugging this bug for Legacy version of GRUB.  Not worth it IMHO, since it
is going to disappear really soon now.

How about if we solve this in grub-installer by probing for amd64/qemu and
switching to GRUB 2 when found?

See attached patch.  The `archdetect' part for subarch-x86-linux.c is loosely
based on code from the mips variant.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
Index: libdebian-installer/src/system/subarch-x86-linux.c
===================================================================
--- libdebian-installer/src/system/subarch-x86-linux.c	(revision 51176)
+++ libdebian-installer/src/system/subarch-x86-linux.c	(working copy)
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -218,10 +219,47 @@
 	{ NULL, NULL }
 };
 
+/* Begin /proc/cpuinfo tests. */
+
+struct systype {
+	char *sys;
+	char *ret;
+};
+
+/* add new system types here */
+
+static struct systype system_type[] = {
+	{"QEMU ", "qemu" },
+	{ NULL, "generic" }
+};
+
+#define INVALID_SYS_IDX (sizeof(system_type) / sizeof(struct systype) - 1)
+#define INVALID_CPU_IDX (-1)
+
+#define BUFFER_LENGTH (1024)
+
+static int check_system(const char *entry)
+{
+	int ret;
+
+	for (ret = 0; system_type[ret].sys; ret++) {
+		if (!strncmp(system_type[ret].sys, entry,
+			     strlen(system_type[ret].sys)))
+			break;
+	}
+
+	return ret;
+}
+
 const char *di_system_subarch_analyze(void)
 {
 	char *manufacturer = dmi_system_manufacturer();
 	int i;
+	FILE *file;
+	int sys_idx = INVALID_SYS_IDX;
+	char buf[BUFFER_LENGTH];
+        char *pos;
+	size_t len;
 
 	if (manufacturer)
 	{
@@ -234,5 +272,19 @@
 		}
 	}
 
-	return "generic";
+	if (!(file = fopen("/proc/cpuinfo", "r")))
+		return system_type[sys_idx].ret;
+
+	while (fgets(buf, sizeof(buf), file)) {
+		if (!(pos = strchr(buf, ':')))
+			continue;
+		if (!(len = strspn(pos, ": \t")))
+			continue;
+		if (!strncmp(buf, "model name", sizeof("model name")-1))
+			sys_idx = check_system(pos + len);
+	}
+
+	fclose(file);
+
+	return system_type[sys_idx].ret;
 }
Index: arch/i386/grub-installer/grub-installer
===================================================================
--- arch/i386/grub-installer/grub-installer	(revision 51176)
+++ arch/i386/grub-installer/grub-installer	(working copy)
@@ -294,6 +294,10 @@
 		grub_package="grub"
 	fi
 	;;
+    amd64/qemu)
+	# GRUB Legacy has trouble on amd64 qemu (see #425648)
+	grub_package="grub-pc"
+	;;
     i386/*|amd64/*)
 	# On PC/BIOS, default to GRUB Legacy
 	grub_package="grub"

Reply to: