[libvirt] Re: [Libvir] ISCSI howto, example, etc?
Chris Lalancette
clalance at redhat.com
Wed May 14 13:19:58 UTC 2008
Stefan de Konink wrote:
> Fix:
> snprintf(sysfs_path, PATH_MAX,
> "/sys/class/iscsi_session/session%s/device/"
> "target%d:%d:%d/%d:%d:%d:%d",
> session, target, channel, id, target, channel, id, lun);
>
>
> (so remove /block)
>
> /* OK, not . or ..; let's see if it is a SCSI device */
> if (len > 8 &&
> block_dirent->d_name[0] == 'b' &&
> block_dirent->d_name[1] == 'l' &&
> block_dirent->d_name[2] == 'o' &&
> block_dirent->d_name[3] == 'c' &&
> block_dirent->d_name[4] == 'k' &&
> block_dirent->d_name[5] == ':' &&
> block_dirent->d_name[6] == 's' &&
> block_dirent->d_name[7] == 'd') {
> /* looks like a scsi device, smells like scsi device; it must be
> a scsi device */
> dev = (char *) calloc(sizeof(char), len - 5);
> strncpy(dev, &(block_dirent->d_name[6]), (len - 6));
>
> I guess that can be come a strncmp. And for sake of memory management an
> if (dev != NULL) would be good too.
Yes, except the problem with your patch is that it will probably break the
kernel I made the fixes for originally, which was either 2.6.23 or 2.6.24 (and
which had the /sys/class/iscsi_session/session9/device/target9:0:0:0/
9:0:0:0/block/sdd type paths). We may be able to come up with a hybrid solution
that will work on both cases, though.
Chris Lalancette
More information about the libvir-list
mailing list