Rather than only permitting SCSI_DISK0_MAJOR, permit all that blkfront
supports. However, as it is unclear to me what the meaning of major
is on non-Linux (it seems questionable whether non-Linux, if using a
similar major/minor concept, would happen to use major 8 as the first
SCSI disk one), do this extension on Linux only.
Also, is it intentional that the /dev/ prefix (accepted by xm) is not
accepted on the third argument by xl?
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
--- 2010-09-20.orig/tools/libxl/libxl_device.c 2010-09-13 08:54:25.000000000
+0200
+++ 2010-09-20/tools/libxl/libxl_device.c 2010-09-21 12:38:09.000000000
+0200
@@ -194,6 +194,18 @@ int libxl__device_disk_dev_number(char *
char *ep;
unsigned long ul;
int chrused;
+ static const unsigned char scsi_majors[] = {
+#ifdef __linux__
+ SCSI_DISK0_MAJOR, SCSI_DISK1_MAJOR, SCSI_DISK2_MAJOR,
+ SCSI_DISK3_MAJOR, SCSI_DISK4_MAJOR, SCSI_DISK5_MAJOR,
+ SCSI_DISK6_MAJOR, SCSI_DISK7_MAJOR, SCSI_DISK8_MAJOR,
+ SCSI_DISK9_MAJOR, SCSI_DISK10_MAJOR, SCSI_DISK11_MAJOR,
+ SCSI_DISK12_MAJOR, SCSI_DISK13_MAJOR, SCSI_DISK14_MAJOR,
+ SCSI_DISK15_MAJOR, SCSI_CDROM_MAJOR
+#else
+ 8
+#endif
+ };
chrused = -1;
if ((sscanf(virtpath, "d%ip%i%n", &disk, &partition, &chrused) >= 2
@@ -219,9 +231,9 @@ int libxl__device_disk_dev_number(char *
return ((disk<2 ? 3 : 22) << 8) | ((disk & 1) << 6) | partition;
}
if (device_virtdisk_matches(virtpath, "sd",
- &disk, 15,
+ &disk, ARRAY_SIZE(scsi_majors) * 16 - 1,
&partition, 15)) {
- return (8 << 8) | (disk << 4) | partition;
+ return (scsi_majors[disk >> 4] << 8) | ((disk & 0xf) << 4) | partition;
}
return -1;
}
--- 2010-09-20.orig/tools/libxl/libxl_osdeps.h 2010-08-06 08:44:33.000000000
+0200
+++ 2010-09-20/tools/libxl/libxl_osdeps.h 2010-09-21 12:21:00.000000000
+0200
@@ -27,6 +27,7 @@
#include <util.h>
#elif defined(__linux__)
#include <pty.h>
+#include <linux/major.h>
#elif defined(__sun__)
#include <stropts.h>
#endif
xl-block-scsi.patch
Description: Text document
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|