Hello,

to solve the problem for me, i have copied a few lines from grub2 version 1.99
to the old squeeze version 1.98+20100804-14 and applied the patch
(hostdisk.diff) from Vladimir 'φ-coder/phcoder' Serbinenko to it. With the
attached patch applied, the grub-probe command returns:

# grub-probe -t abstraction --device /dev/xvda1 -v
grub-probe: info: Cannot stat `/dev/xvda', skipping.
grub-probe: info: /dev/xvda1 starts from 0.
grub-probe: info: opening the device /dev/xvda.
grub-probe: warn: disk does not exist, so falling back to partition device
/dev/xvda1.
grub-probe: info: opening /dev/xvda1.
grub-probe: info: the size of /dev/xvda1 is 12582912.

and update-grub works without error.

--- a/kern/emu/hostdisk.c	2010-08-04 05:40:55.000000000 +0200
+++ b/kern/emu/hostdisk.c	2011-06-01 17:26:04.429479379 +0200
@@ -1353,12 +1353,16 @@
 #endif /* defined(__NetBSD__) */
 
 static int
-find_system_device (const char *os_dev, struct stat *st)
+find_system_device (const char *os_dev, struct stat *st, int convert)
 {
   unsigned int i;
   char *os_disk;
 
   os_disk = convert_system_partition_to_system_disk (os_dev, st);
+  if (convert)
+    os_disk = convert_system_partition_to_system_disk (os_dev, st);
+  else
+    os_disk = xstrdup (os_dev);
   if (! os_disk)
     return -1;
 
@@ -1392,7 +1396,7 @@
       return 0;
     }
 
-  drive = find_system_device (os_dev, &st);
+  drive = find_system_device (os_dev, &st, 1);
   if (drive < 0)
     {
       grub_error (GRUB_ERR_UNKNOWN_DEVICE,
@@ -1498,7 +1502,33 @@
     free (name);
 
     if (! disk)
-      return 0;
+      {
+      /* We already know that the partition exists.  Given that we already
+        checked the device map above, we can only get GRUB_ERR_UNKNOWN_DEVICE
+        or GRUB_ERR_BAD_DEVICE at this point if the disk does not exist.
+        This can happen on Xen, where disk images in the host can be
+        assigned to devices that have partition-like names in the guest
+        but are really more like disks.  */
+      if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE ||
+          grub_errno == GRUB_ERR_BAD_DEVICE)
+        {
+        grub_util_warn
+            ("disk does not exist, so falling back to partition device %s",
+            os_dev);
+
+        drive = find_system_device (os_dev, &st, 0);
+        if (drive < 0)
+          {
+          grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+                  "no mapping exists for `%s'", os_dev);
+          return 0;
+          }
+
+          return make_device_name (drive, -1, -1);
+        }
+      else
+        return 0;
+      }
 
     partname = NULL;
     grub_partition_iterate (disk, find_partition);

Reply via email to