Jan Beulich
2010-Sep-21 11:17 UTC
[Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping
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@novell.com> --- 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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Sep-21 15:31 UTC
Re: [Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping
Jan Beulich writes ("[Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping"):> 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.I think this is wrong, I''m afraid. Firstly, according to the document I''m trying to get agreed (see my mail just sent, with another copy of it), sd* devices beyond disk 15 are deprecated and not supported. You should be using xvd* if you can. For backwards compatibility we do support specifying the plain xenstore number, in decimal, hex or octal. So you can use that if you have old guests which for some reason you can''t change.> +#ifdef __linux__Secondly, that is entirely wrong, because that switches on the operating system in dom0. That may be entirely different to the operating system in the guest. That shows why this whole idea of trying to specify the major/minor numbers in the guest is wrong. Some guests may not even _have_ major/minor numbers. The environment provided to a Xen guest should not reference Linux-specific numbering schemes. For historical reasons (ie, people having made this mistake in the past), we have to import and redefine some existing usages. That''s what my document does. However:> Also, is it intentional that the /dev/ prefix (accepted by xm) is not > accepted on the third argument by xl?/dev doesn''t make much sense once you look at it in the way I do, above, but this should be supported for compatibility. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2010-Sep-21 16:25 UTC
Re: [Xen-devel] [PATCH] xl: (Linux) extend SCSI device name to major mapping
>>> On 21.09.10 at 17:31, Ian Jackson <Ian.Jackson@eu.citrix.com> wrote: > Firstly, according to the document I''m trying to get agreed (see my > mail just sent, with another copy of it), sd* devices beyond disk 15 > are deprecated and not supported. You should be using xvd* if you > can.Sure. I was just trying to test the SCSI path that someone else used and reported a problem with. I wasn''t able to use the first major (as that is necessarily used by sd.ko), but I could free up all other majors for blkfront.> For backwards compatibility we do support specifying the plain > xenstore number, in decimal, hex or octal. So you can use that if you > have old guests which for some reason you can''t change.Okay, that might also have worked then for this specific exercise. It''s only a little cumbersome to work out those numbers.>> +#ifdef __linux__ > > Secondly, that is entirely wrong, because that switches on the > operating system in dom0. That may be entirely different to the > operating system in the guest. That shows why this whole idea of > trying to specify the major/minor numbers in the guest is wrong. Some > guests may not even _have_ major/minor numbers.I would agree, wouldn''t there already be the use of Linux majors for SCSI and IDE (for the latter, even including both majors). Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel