Cheers I'll look tomorrow when time permits :) Sent from my iPhone On 22/08/2010, at 9:02, "Nicholas A. Bellinger" <nab@xxxxxxxxxxxxxxx> wrote: > On Sat, 2010-08-21 at 16:07 +1000, Mark Harvey wrote: >> Apologies for including this patch as an attachment.. >> I haven't figured out how to successfully do it from the office. >> >> Included inline for easier reading / review. >> >> On Fri, Aug 20, 2010 at 7:29 PM, Nicholas A. Bellinger >> <nab@xxxxxxxxxxxxxxx> wrote: >>> On Fri, 2010-08-20 at 11:22 +0900, FUJITA Tomonori wrote: >>>> On Thu, 19 Aug 2010 12:51:54 -0700 >>>> "Nicholas A. Bellinger" <nab@xxxxxxxxxxxxxxx> wrote: >>>>> So it looks like the failure is attributed to my hardcoding of major 254 >>>>> in the original STGT/BSG patch (note the comment above the conditional >>>>> check). Here is a quick fix: >>>>> >>>>> diff --git a/usr/bs_sg.c b/usr/bs_sg.c >>>>> index cda5cd2..a369570 100644 >>>>> --- a/usr/bs_sg.c >>>>> +++ b/usr/bs_sg.c >>>>> @@ -289,7 +289,7 @@ static int chk_sg_device(char *path) >>>>> return 0; >>>>> >>>>> /* This is not yet defined in include/linux/major.h.. */ >>>>> - if (major(st.st_rdev) == 254) >>>>> + if ((major(st.st_rdev) == 254) || (major(st.st_rdev) == 253)) >>>>> return 1; >>>>> >>>>> return -1; >>>> >>>> Well, seems that nobody uses the bsg support except for you. :) >>>> >>>> The above patch is still wrong. >>>> >>>> bsg major number can be anything. So you need to get it from >>>> /proc/devices. >>>> >>>> Or you can also get it from /sys/class/bsg/, which is created by >>>> kernel so available on any distributions. >>>> >>>> You can steal the bsg device handling code from sg3-utils. Maybe >>>> someone could create something like libbsg.so >>> >>> Hmmm indeed, thanks for point this one out. I will have look at >>> adressing for this the BSG efforts with STGT and QEMU-KVM using the >>> recommended major:minor output from /sys/class/bsg/$HCTL/dev. >>> >>> Best, >>> >>> --nab >>> >>> >> >>> From a90611630879205ef497821552474e894d463c94 Mon Sep 17 00:00:00 2001 >> From: Mark Harvey <markh794@xxxxxxxxx> >> Date: Sat, 21 Aug 2010 15:22:48 +1000 >> Subject: Check bsg major number from /sys/class/bsg/<c:t:l>/dev >> >> Signed-off-by: Mark Harvey <markh794@xxxxxxxxx> >> --- >> usr/bs_sg.c | 35 ++++++++++++++++++++++++++++++++--- >> 1 files changed, 32 insertions(+), 3 deletions(-) >> >> diff --git a/usr/bs_sg.c b/usr/bs_sg.c >> index dfd49c3..7fc9787 100644 >> --- a/usr/bs_sg.c >> +++ b/usr/bs_sg.c >> @@ -269,6 +269,34 @@ static void bs_sg_cmd_complete(int fd, int >> events, void *data) >> cmd->scsi_cmd_done(cmd, io_hdr.status); >> } >> >> +static int get_bsg_major(char *path) >> +{ >> + FILE *devfd; >> + char majorno[8]; >> + char dev[128]; >> + int ch; >> + int i; >> + >> + dev[0] = '\0'; >> + strncat(dev, "/sys/class/bsg/", 16); >> + strncat(dev, &path[9], 64); >> + strncat(dev, "/dev", 5); >> + devfd = fopen(dev, "r"); >> + if (!devfd) >> + return -1; >> + ch = fgetc(devfd); >> + for (i = 0; i < 7; i++) { >> + if (ch == ':') { >> + majorno[i] = '\0'; >> + break; >> + } >> + majorno[i] = ch; >> + ch = fgetc(devfd); >> + } >> + fclose(devfd); >> + return atoi(majorno); >> +} >> + >> static int chk_sg_device(char *path) >> { >> struct stat st; >> @@ -287,9 +315,10 @@ static int chk_sg_device(char *path) >> if (major(st.st_rdev) == SCSI_GENERIC_MAJOR) >> return 0; >> >> - /* This is not yet defined in include/linux/major.h.. */ >> - if (major(st.st_rdev) == 254) >> - return 1; >> + if (!strncmp("/dev/bsg", path, 8)) { >> + if (major(st.st_rdev) == get_bsg_major(path)) >> + return 0; >> + } >> >> return -1; >> } > > Hi Mark, > > Here is my updated version of your initial code for the megasas > 8708EM2 / SGL passthrough friendly qemu-kvm.git/scsi-bsg: > > http://git.kernel.org/?p=virt/kvm/nab/qemu-kvm.git;a=commitdiff;h=075901d9bc1fea670bef84f55806f1bc8b2a5e9e > > Please feel free to improve your patch using this code and respin > another patch for tomo-san to review. > > Thanks! > > --nab > > -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html