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-devel

[Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Tue, 21 Sep 2010 12:17:55 +0100
Delivery-date: Tue, 21 Sep 2010 04:18:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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



Attachment: xl-block-scsi.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>